Hard to find failing tests when using NUnit SouceValueAttribute
Using NUnit SourceValue attribute when I run the tests bellow I see
Test(TestSpec) (image bellow).
When a test fail it is dificult to know which one failed.
Is there a way to get NUnit to dump which value it is using for each of
the tests?
class C
{
public static int DoIt(int i)
{
return i * i;
}
}
class TestClass
{
public void Test([SourceValue("TestData")] TestSpec testSpec)
{
Assert.Equals(testSpec.Expectation, C.DoIt(testSpec.Value));
}
public static IEnumerable<TestSpec> TestData()
{
return new []
{
new TestSpec(1, 1),
new TestSpec(2, 4),
new TestSpec(3, 9),
new TestSpec(4, 16),
};
}
}
class TestSpec
{
public TestSpec(int expectation, int value)
{
Expectation = expectation;
Value = value;
}
public int Expectation { get; set; }
public int Value { get; set; }
}
No comments:
Post a Comment