Build/Test Issues

NUnit TestCase without TestName

Started by BradIrby on 4,202 views

There seems to be a problem running NUnit 3.6.1 tests using unnamed TestCases. In these two test cases, the second test is passing when it should be failing.


[TestFixture]
public class SampleArrayTests
{

[TestCase(new int[] { 5, 2, 7, 8 }, TestName = "good1")]
[TestCase(new int[] { 9, 0, 1 }, TestName = "bad")]
[TestCase(new int[] { 5, 6, 7, 8 }, TestName = "good2")]
public void TestCasesWithNames_Arr(int[] array)
{
Assert.That(array.Length, Is.EqualTo(4));
}

[TestCase(new int[] { 5, 2, 7, 8 })]
[TestCase(new int[] { 5, 6, 7, 8 })]
[TestCase(new int[] { 9, 0, 1 })]
public void TestCasesWithoutNames_Arr(int[] array)
{
Assert.That(array.Length, Is.EqualTo(4));
}

}



Change the order of the TestCases in the second test and it will pass or fail at random. If you copy/paste the second test into another test, the second will fail.



[TestFixture]
public class SampleArrayTests
{

[TestCase(new int[] { 5, 2, 7, 8 }, TestName = "good1")]
[TestCase(new int[] { 9, 0, 1 }, TestName = "bad")]
[TestCase(new int[] { 5, 6, 7, 8 }, TestName = "good2")]
public void TestCasesWithNames_Arr(int[] array)
{
Assert.That(array.Length, Is.EqualTo(4));
}

[TestCase(new int[] { 5, 6, 7, 8 })]
[TestCase(new int[] { 9, 0, 1 })]
[TestCase(new int[] { 5, 6, 7, 8 })]
public void TestCasesWithoutNames_Arr(int[] array)
{
Assert.That(array.Length, Is.EqualTo(4));
}

[TestCase(new int[] { 5, 6, 7, 8 })]
[TestCase(new int[] { 9, 0, 1 })]
[TestCase(new int[] { 5, 6, 7, 8 })]
public void TestCasesWithoutNames_Arr2(int[] array)
{
Assert.That(array.Length, Is.EqualTo(4));
}

}


[img=http://bradirby.com/wp-content/uploads/2017/08/NCrunchError.png]ErrorsInTestCaseNames[/img]
Hi,

Thanks for taking the time to report this. With this code sample, you've helped me to corner a bug that I've been trying to figure out for several weeks.

NCrunch is feeding old removed tests into the pipeline. This is causing downstream instability in NUnit3, because it interferes with test identification in the test process. The problem in this case was surfaced by removing and replacing the 'bad' testcase several times.

I'm pushing to have a new release out by early next week. I'll make sure a fix for this problem is included.

If you encounter this again, a simple reset of the engine should get rid of it.

Post a reply

Log in to reply.