phpunitHow to stop PHPUnit on failure?
You can stop PHPUnit on failure by using the stopOnFailure
option. This option will cause PHPUnit to stop execution after the first failure.
Example code
$ phpunit --stop-on-failure
Output example
PHPUnit 6.5.14 by Sebastian Bergmann and contributors.
.F
Time: 1.02 seconds, Memory: 10.00MB
There was 1 failure:
1) Tests\ExampleTest::testTrue
Failed asserting that false is true.
/path/to/ExampleTest.php:14
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
The stopOnFailure
option is a boolean option, which means it can be set to either true
or false
. When set to true
, PHPUnit will stop execution after the first failure. When set to false
, PHPUnit will continue execution even after a failure.
Code explanation
--stop-on-failure
: This is the option that will cause PHPUnit to stop execution after the first failure.true
: When set totrue
, PHPUnit will stop execution after the first failure.false
: When set tofalse
, PHPUnit will continue execution even after a failure.
Helpful links
More of Phpunit
- How to skip a PHPUnit test?
- How to mock a method with different arguments in PHPUnit?
- How to run tests in parallel with PHPUnit?
- How to run all PHPUnit tests?
- How to run only certain methods in PHPUnit?
- How to mock a static method with PHPUnit?
- How to mock a query builder with PHPUnit?
- How to launch one test with PHPUnit?
- How to check if a JSON contains a value in PHPUnit?
- How to use hooks in PHPUnit?
See more codes...