153

I'm running a large suite of phpunit tests, and I'd like see which test failed as soon as it failed, rather than waiting for all of the tests to complete then having it list out all of the failures.

How can I tell phpunit to do this?

1 Answer 1

269

Add the stopOnFailure="true" attribute to your phpunit.xml root element.

You can also use it in the CLI: phpunit --stop-on-failure

Info from manual and some others that are maybe useful for you:

  • stopOnError - "Stop execution upon first error."
  • stopOnFailure - "Stop execution upon first error or failure."
  • stopOnIncomplete - "Stop execution upon first incomplete test."

More info at: PHPunit manual

2
  • 1
    At least as of PHPUnit 11, the "stopOnFailure" doesn't stop on errors anymore. A combination of "--stop-on-error" and "--stop-on-failure" does the trick. Docs: docs.phpunit.de/en/11.0/textui.html#automatically-stop-when Commented Feb 11 at 15:14
  • 1
    @SjorsOttjes --stop-on-failure isn't working for me any more at all? PHPUnit 10.5.13. --stop-on-defect works however. Commented Mar 19 at 14:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.