Assumptions
Sometimes, unit tests can be relevant only when certain conditions are met. This is often the case with parameterized tests.
In these cases, mapping these conditions as assertions would mark as failed tests that simply received invalid data. To obviate this issue, NUnit offers the possibility to make assumptions on the incoming data. Unlike assertions, unmet assumptions make the runner mark the test as Invalid instead of Failed.
In the example above, test runs with invalid day/month/year combinations (like June 31st) are ignored.
Please note that assumptions make use of the Assume
static class. Assume.That
has the same set of overloads as Assert.That
.
Last updated