Inconclusive test states are used primarily for row tests, integration tests, and theories.
Theories are used like this:
Code:
[Datapoints]
int[] possibleComparisonResults = { -100, -2, -1, 0, 1, 100, 1000, int.MaxValue, int.MinValue };
[Theory]
Reverse_WhenPassedValidValues_Succeeds(int comparisonResult)
{
var newResult = MyClass.ReverseComparison(comparisonResult);
Assert.That(Math.Sign(newResult), Is.EqualTo(-Math.Sign(comparisonResult)));
}
What NUnit will do in this scenario is apply every combination of arguments to the function as test cases. That is to say that a theory is a short-hand way of writing 100's or 1000's of test cases.
The purpose of Inconclusive tests is so that you can ignore
some of the tests generated by a theory.
For example:
Code:
[Datapoints]
int[] values = { int.MinValue, -1, 0, 1, 2, 3, 5, 7, 10, 64, 100, 1000, 10000, int.MaxValue };
[Theory]
MyDivRem_WhenPassedValidValues_ReturnsTheProperRemainder(int dividend, int divisor)
{
Assume.That(divisor, Is.Not.EqualTo(0));
var quotient = a / b;
var remainder = a % b;
// etc...
}
In the example above, there will be 196 (14 * 14) test cases generated. That's too many to write by hand as '[TestCase]' attributes. However, we are wanting to
avoid testing division-by-zero-behavior in this test. So, we use the "Assume" class in order to short circuit the test early.
However, that means that there will be 14 "inconclusive" states under this theory.
NUnit considers a test with tests cases as "passed" if:
- The test has no failed test cases, and
- The test has at least one passed test case
Conversely, NUnit considers a test with test cases as "failed" if:
- The test has at least one failed test cases, or
- The test has no passed test case
To sum it up, as long as a test has a mixture only of one or more "Pass" and any number of "Inconclusive" results in its test cases, the test is considered a pass.