【发布时间】:2016-05-29 22:25:48
【问题描述】:
我有大量类似的测试,我使用 MemberData 属性作为理论来实现。如何导航到每个失败的测试用例并对其进行调试?
这里是一个例子:
public const int A = 2;
public const int B = 3;
public const int C = 2;
public static IEnumerable<object[]> GetTestCases
{
get
{
// 1st test case
yield return new object[]
{
A, B, 4
};
// 2nd test case
yield return new object[]
{
A, C, 4
};
}
}
[Theory]
[MemberData("GetTestCases")]
public void TestMethod1(int operand1, int operand2, int expected)
{
// Q: How can I debug only test case, which is failed?
//...and break execution before exception will be raised
var actual = operand1 + operand2;
Assert.Equal(actual, expected);
}
【问题讨论】:
标签: c# unit-testing xunit