PexAssume
Static class to express
assumptions, i.e. a
precondition, in
parameterized unit tests. The methods of this class can be used to filter out undesirable test inputs.
If the assumed condition does not hold for some test input, a
PexAssumeFailedException is thrown, which will cause the test to be silently ignored.
Example
The following parameterized test will not consider j=0.
public void TestSomething(int i, int j) {
PexAssume.AreNotEqual(j, 0);
int k = i/j;
...
}
Remarks
The code above is almost equivalent to
except that a failing
PexAssume results in no test cases, whereas in the case of an if-statement, Pex would generate a separate test case to cover the then-branch of the if-statement.
PexAssume also contains specialzed nested classes for assumptions on string, arrays and collections.
See Also
PexAssert,
PexSymbolicValue