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 show warnings in PHPUnit?
- How to mock a method with different arguments in PHPUnit?
- How to test protected methods in PHPUnit?
- How to use the PHPUnit Framework TestCase?
- How to skip a PHPUnit test?
- How to log to the console with PHPUnit?
- How to ignore a test in PHPUnit?
- How to run only certain methods in PHPUnit?
- How to mock a private method in PHPUnit?
See more codes...