开发者

Is there a way to use MSTest to run all tests for a set of parameters?

I just have one parameter that can take two values. I would like t开发者_StackOverflowo see two sets of my tests in the test runner, one for the first value, one for the second. How can I do this?


Can use the [DataSource] attribute too:

http://callumhibbert.blogspot.com/2009/07/data-driven-tests-with-mstest.html

http://codeclimber.net.nz/archive/2008/01/18/How-to-simulate-RowTest-with-MS-Test.aspx


MSTest is very limited, but it never really troubled me. You can do parameterized tests like this:

[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);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜