Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

NUnit TestCase without TestName
BradIrby
#1 Posted : Wednesday, August 30, 2017 3:39:49 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/30/2017(UTC)
Posts: 1
Location: United States of America

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.

Quote:

[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.

Quote:


[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));
}

}


ErrorsInTestCaseNames
Remco
#2 Posted : Thursday, August 31, 2017 12:48:05 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,975

Thanks: 929 times
Was thanked: 1257 time(s) in 1170 post(s)
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.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.038 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download