.netunit-testingnunit

NUnit, is it possible to continue executing test after Assert fails?


In a test that contains some asserts, for example:

Assert.AreEqual(1,1);
Assert.AreEqual(2,1);
Assert.AreEqual(2,2);

is it possible to let the test keep running after it fails at some point? In the example, first condition is true, second fails and the test stops. I'd like to evaluate also the following condition.


Solution

  • NUnit 3.6 adds Assert.Multiple method and MultipleAsserts attribute.

    enter image description here

    See https://docs.nunit.org/articles/nunit/writing-tests/assertions/multiple-asserts.html