1
我有大量的类似测试,我使用MemberData属性作为理论实现。我如何导航到每个堕落的测试用例并进行调试?如何在xunit测试中调试理论
下面的例子:
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);
}
这也取决于你使用哪个IDE,因为每个扩展都有必要的支持让你通过IDE集成轻松调试一个理论。 –
我使用Visual Studio和ReSharper。但他们不能(或者我没有找到如何)导航到代码行,在这里定义了选定测试用例的数据。你可以推荐这样的xUnit扩展吗? – Win4ster