[英]Is there a way to use MSTest to run all tests for a set of parameters?
我只有一個參數,可以采用兩個值。 我想在測試運行器中看到兩組測試,一組用於第一個值,一組用於第二個值。 我怎樣才能做到這一點?
MSTest非常有限,但它從未真正困擾過我。 您可以像這樣進行參數化測試:
[TestMethod] public void SomeMethod_WithValidArgs1_Succeeds()
{
Assert_ThatSomeMethodSucceeds(0, "bla");
}
[TestMethod] public void SomeMethod_WithValidArgs2_Succeeds()
{
Assert_ThatSomeMethodSucceeds(1, "bla");
}
[TestMethod] public void SomeMethod_WithValidArgs3_Succeeds()
{
Assert_ThatSomeMethodSucceeds(1, "funcy");
}
private static void Assert_ThatSomeMethodSucceeds(
int param1, string param2)
{
// Act
SubSystem.SomeMethod(param1, param2);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.