2

Is there a way in MSTest to not run a test when certain assumptions are invalid? Like JUnit's "Assume.*" methods:

//Setup
Assume.assumeEquals(2, count);
//Only run the rest of the test when count==2

I realize that I can easily write my own "Assume*" Methods like this:

public static void AssumeEqual(Object expected, Object actual, string valueName = "value")
{
    if (!Object.Equals(expected, actual))
    {
        Assert.Inconclusive("Assumed \"" + valueName + "\"==\"" + expected + "\", but was \"" + actual + "\".");
    }
}

But if there is a built in way I would rather use it than writing my own.

David Tanzer
  • 2,732
  • 18
  • 30

1 Answers1

1

No. There is no inbuilt way. If you are looking at some alternatives/addons to the Asserts in mstest you can look at Fluent Assertions on codeplex.

allen
  • 4,627
  • 1
  • 22
  • 33