1

I want to stop further execution of Tests within a TestFixture if one of them fails in NUnit.

Of course the common and advised practice is to make tests independent of each other. However, the case I would like to use NUnit for, requires that all tests and test fixtures following one that failed, are not executed. In other words, test failure causes the whole NUnit execution to stop (or proceeds with the next [TestFixture] but both scenarios should be configurable).

The simple, yet not acceptable solution, would be to force NUnit termination by sending a signal of some kind to the NUnit process.

Is there a way to do this in an elegant way?

Jacek M
  • 2,349
  • 5
  • 22
  • 47
  • This question has been answered before. Have a look [here](https://stackoverflow.com/questions/7657767/how-to-make-nunit-stop-executing-tests-on-first-failure). – Vapour in the Alley Aug 09 '19 at 23:14
  • This question was asked in Feb 2011 and the one you refer to in Oct 2011, so no, it has not been asked "before" and rather the reverse is true. – Jacek M Aug 10 '19 at 06:41

1 Answers1

1

I believe you can use NAnt to do this. Specifically, the nunit or nunit2 tasks have a haltonfailure parameter that allows the test run to stop if a test fails.

Bernard
  • 7,908
  • 2
  • 36
  • 33
  • _nunit_ and _nunit2_ tasks in the current version of NAnt both depend on a specific NUnit version, therefore, using latest release, e.g., 2.5.9 is not possible. This can be solved using [exec](http://nant.sourceforge.net/release/0.85/help/tasks/exec.html) task, however, it does not provide a **haltonfailure** parameter and it does not work as I would expect with **failonerror**. Using NAnt was a good suggestion anyways and it might have worked if I was not forced to use a specific NUnit version in my project. – Jacek M Feb 14 '11 at 14:35