Build/Test Issues

DynamicData Attribute Requires Public Access to Property?

Started by kweinberg on 2,380 views

Hello!

I've been working on configuring our code to execute our tests through NCrunch. I'm having to change several private members of my classes to be public in order for some tests to work. These tests work properly when executed through Visual Studio, but not through NCrunch. Is this a bug? Is there another way around this?

For example, I have a test using the DynamicData attribute where the supplied source data name is a private property.

private static IEnumerable<object[]> TestParameters { get; } = GetTestParameters();

[DataTestMethod]
[DynamicData(nameof(TestParameters))]
public Task ExampleUnitTest(TestParams testParams)
{
	return Task.CompletedTask;
}


The error NCrunch gives is:

Unable to resolve dynamic data source method: Test.UnitTestClassName::get_TestParameters


Making TestParameters public will fix this error.

Thanks!

Kevin
Thanks Kevin. We weren't aware that MSTest would work with these methods when they were private. I've made a note to see if we can get this fixed.
This post has been deleted.
Hi Kevin,

Sorry this has taken a while to complete. This will be fixed in the next version. This should be released in the near future.
The next version isn't released yet. This is an incremental build that contains the fix. If you want you can give it a try!

NCrunch_Console_4.3.0.7.msi
NCrunch_Console_4.3.0.7.zip
NCrunch_GridNodeServer_4.3.0.7.msi
NCrunch_GridNodeServer_4.3.0.7.zip
NCrunch_LicenseServer_4.3.0.7.zip
NCrunch_VS2008_4.3.0.7.msi
NCrunch_VS2010_4.3.0.7.msi
NCrunch_VS2010_4.3.0.7.zip
NCrunch_VS2012_4.3.0.7.msi
NCrunch_VS2012_4.3.0.7.zip
NCrunch_VS2013_4.3.0.7.msi
NCrunch_VS2013_4.3.0.7.zip
NCrunch_VS2015_4.3.0.7.msi
NCrunch_VS2015_4.3.0.7.msi.7z
NCrunch_VS2015_4.3.0.7.zip
NCrunch_VS2017_4.3.0.7.msi
NCrunch_VS2017_4.3.0.7.msi.7z
NCrunch_VS2017_4.3.0.7.zip
NCrunch_VS2019_4.3.0.7.msi
NCrunch_VS2019_4.3.0.7.msi.7z
NCrunch_VS2019_4.3.0.7.zip

Post a reply

Log in to reply.