How to tell phpunit to stop on failure

johncorser picture johncorser · May 4, 2015 · Viewed 28.4k times · Source

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?

Answer

Sven van Zoelen picture Sven van Zoelen · May 4, 2015

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