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