public class SomeImplementation : ISomeImplementation
{
public bool DoSomething()
{
return true;
}
}
[TestClass, TestCategory("NCrunch.DynamicData")]
public class ImplementationDynamicDataTest
{
/*
* NCrunch analyse process dies at test with class variables provided as null input:
*
* An error occurred while analysing this project after it was built: System.NullReferenceException: Object reference not set to an instance of an object.
* at System.Object.GetType()
* at nCrunch.Module.MSTest.Integration.MSTestDynamicDiscoverer.<createDynamicDataSourceTests>b__7_0(Object p)
* at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
* at nCrunch.Module.MSTest.Integration.MSTestDynamicDiscoverer.createDynamicDataSourceTests(List`1 frameworkTests, IMSTestParameterSupplier parameterSupplier, ReflectedMethod method, ReflectedType fixture, Factory testNameFactory)
* at nCrunch.Module.MSTest.Integration.MSTestDynamicDiscoverer.<>c__DisplayClass5_0.<FindFrameworkTestsInAssembly>b__1()
* at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
* at nCrunch.Module.MSTest.Integration.MSTestDynamicDiscoverer.FindFrameworkTestsInAssembly(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, ComponentUniqueName testComponentUniqueName, PlatformType platformType, DynamicProxy[] dynamicProxies)
* at nCrunch.TestExecution.TestFinder.<>c__DisplayClass2_2.<FindTestsForFrameworks>b__2()
* at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
* at nCrunch.TestExecution.TestFinder.<>c__DisplayClass2_0.<FindTestsForFrameworks>b__0()
* at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
* at nCrunch.TestExecution.TestFinder.FindTestsForFrameworks(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, DescribedTestFrameworkDiscoverer[] describedDiscoverers, ComponentUniqueName testComponentUniqueName, PlatformType platformType, DynamicProxy[] dynamicProxies)
* at nCrunch.TestExecution.RemoteTaskRunner.AnalyseAssembly(DescribedTestFrameworkDiscoverer[] applicableFrameworks, ComponentUniqueName testComponentUniqueName, PerfTracker perfTracker)
*
*/
public static IEnumerable<object[]> DoSomethingTestData
{
get
{
yield return new object[] {null, false, "Missing implementation" };
yield return new object[] { new SomeImplementation(), true, "Implementation executed" };
}
}
public class ImplementationContainer
{
public SomeImplementation Implementation { get; set; }
}
public class ClassUnderTest
{
public bool Execute(ImplementationContainer container)
{
return container?.Implementation?.DoSomething() ?? false;
}
}
[DataTestMethod]
[DynamicData(nameof(DoSomethingTestData), DynamicDataSourceType.Property)]
public void DoSomethingTest(SomeImplementation implementation, bool expected, string description)
{
var container = new ImplementationContainer
{
Implementation = implementation
};
var classUnderTest = new ClassUnderTest();
classUnderTest.Execute(container).Should().Be(expected, description);
}
}
Build/Test Issues
BUG: DynamicData does not work properly for class with null test
Started by TKrueger on 3,955 views
Remco NCrunch Developer
#13170
04 Mar 2019 22:18 UTC
My apologies for the time it's taken to get back to you on this issue. The initial report slipped our net. The build below contains a targeted fix. Would you be interested in giving it a try?
NCrunch_Console_3.24.0.3.msi
NCrunch_Console_3.24.0.3.zip
NCrunch_GridNodeServer_3.24.0.3.msi
NCrunch_GridNodeServer_3.24.0.3.zip
NCrunch_LicenseServer_3.24.0.3.zip
NCrunch_VS2008_3.24.0.3.msi
NCrunch_VS2010_3.24.0.3.msi
NCrunch_VS2010_3.24.0.3.zip
NCrunch_VS2012_3.24.0.3.msi
NCrunch_VS2012_3.24.0.3.zip
NCrunch_VS2013_3.24.0.3.msi
NCrunch_VS2013_3.24.0.3.zip
NCrunch_VS2015_3.24.0.3.msi
NCrunch_VS2015_3.24.0.3.msi.7z
NCrunch_VS2015_3.24.0.3.zip
NCrunch_VS2017_3.24.0.3.msi
NCrunch_VS2017_3.24.0.3.msi.7z
NCrunch_VS2017_3.24.0.3.zip
NCrunch_Console_3.24.0.3.msi
NCrunch_Console_3.24.0.3.zip
NCrunch_GridNodeServer_3.24.0.3.msi
NCrunch_GridNodeServer_3.24.0.3.zip
NCrunch_LicenseServer_3.24.0.3.zip
NCrunch_VS2008_3.24.0.3.msi
NCrunch_VS2010_3.24.0.3.msi
NCrunch_VS2010_3.24.0.3.zip
NCrunch_VS2012_3.24.0.3.msi
NCrunch_VS2012_3.24.0.3.zip
NCrunch_VS2013_3.24.0.3.msi
NCrunch_VS2013_3.24.0.3.zip
NCrunch_VS2015_3.24.0.3.msi
NCrunch_VS2015_3.24.0.3.msi.7z
NCrunch_VS2015_3.24.0.3.zip
NCrunch_VS2017_3.24.0.3.msi
NCrunch_VS2017_3.24.0.3.msi.7z
NCrunch_VS2017_3.24.0.3.zip
Hello,
I tried the new version in my test project. There the test has now been successfully completed.
Unfortunately I have determined an other issue in my main application which relates to the current issue.
I have updated my test project and can reproduce the issuse with the following adjustment:
Now I get this message:
Can you please also check this problem?
Thanks
I tried the new version in my test project. There the test has now been successfully completed.
Unfortunately I have determined an other issue in my main application which relates to the current issue.
I have updated my test project and can reproduce the issuse with the following adjustment:
[DataTestMethod]
[DynamicData(nameof(DoSomethingTestData), DynamicDataSourceType.Property)]
public void DoSomethingWithObjectsTest(SomeImplementation implementation, bool expected, string description)
{
implementation.Should().NotBeNull();
// or this (make no difference)
//Assert.IsNotNull(implementation);
}
Now I get this message:
NCrunch: The test cases for this test cannot be reported individually by NCrunch because at least one of the parameters being supplied is not a primitive type. For full test case decomposition under NCrunch, all test case parameters must be of primitive types.
Can you please also check this problem?
Thanks
Remco NCrunch Developer
#13180
06 Mar 2019 10:22 UTC
TKrueger wrote:Now I get this message:
NCrunch: The test cases for this test cannot be reported individually by NCrunch because at least one of the parameters being supplied is not a primitive type. For full test case decomposition under NCrunch, all test case parameters must be of primitive types.
Can you please also check this problem?
Thanks
In this case, the message you're seeing is behaviour by design.
For NCrunch to decompose a dynamic method into multiple test cases, it needs to be able to uniquely identify the parameters for each test case and serialize them between environments. It isn't really possible to do this reliably with user types (which can only be uniquely identified by memory address), so we just roll up the test cases into a single test and report it in the same way as VSTest does.
Hi,
I have checked my issue again and have to say "sorry my mistake".
I have checked my issue again and have to say "sorry my mistake".
Post a reply
Log in to reply.