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