reveazure
reveazure

Reputation: 673

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 to see two sets of my tests in the test runner, one for the first value, one for the second. How can I do this?

Upvotes: 2

Views: 945

Answers (2)

Steven
Steven

Reputation: 172825

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

Upvotes: 0

Related Questions