Build/Test Issues

BUG: DynamicData does not work properly for StringExtensions

Started by TKrueger on 2,358 views


public static class StringExtensions
{
	/// <summary>
	/// Strips HTML tags from value
	/// </summary>
	/// <param name="value">The value</param>
	/// <returns>Doubled value</returns>
	public static string DoSomething(this string value)
	{
		if (value == null)
		{
			return null;
		}

		return value + value;
	}
}


[TestClass, TestCategory("NCrunch.DynamicData")]
public class StringExtensionDynamicDataTest
{
	/* 
	 * NCrunch analyse process dies at test with extensions with 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[] { "Test", "TestTest", "Doubled input" };
			yield return new object[] { "", "", "Empty string" };
			yield return new object[] { null, null, "Null string" };
		}
	}

	[DataTestMethod]
	[DynamicData(nameof(DoSomethingTestData), DynamicDataSourceType.Property)]
	public void DoSomethingTest(string input, string expected, string description)
	{
		input.DoSomething().Should().Be(expected, description);
	}
}
Hi,

Thanks for sharing this issue. I've reproduced it exactly as you've described.

The problem is related to the nulls inside the object array, but you probably figured this out already :)

I'll see about arranging a fix.
Hi,

Thanks again for sharing this.

If you'd like to get early access to this fix I've posted a new build:

NCrunch_Console_3.24.0.2.msi
NCrunch_Console_3.24.0.2.zip
NCrunch_GridNodeServer_3.24.0.2.msi
NCrunch_GridNodeServer_3.24.0.2.zip
NCrunch_LicenseServer_3.24.0.2.zip
NCrunch_VS2008_3.24.0.2.msi
NCrunch_VS2010_3.24.0.2.msi
NCrunch_VS2010_3.24.0.2.zip
NCrunch_VS2012_3.24.0.2.msi
NCrunch_VS2012_3.24.0.2.zip
NCrunch_VS2013_3.24.0.2.msi
NCrunch_VS2013_3.24.0.2.zip
NCrunch_VS2015_3.24.0.2.msi
NCrunch_VS2015_3.24.0.2.msi.7z
NCrunch_VS2015_3.24.0.2.zip
NCrunch_VS2017_3.24.0.2.msi
NCrunch_VS2017_3.24.0.2.msi.7z
NCrunch_VS2017_3.24.0.2.zip
Hi,

I'm sorry these posts have slipped my attention. I will have a look at them.

I'm glad that at least this is fixed. :)

Michael

Post a reply

Log in to reply.