You may use --stop-on-failure
flag to break the unit testing when one of the tests fails.
Is there any way quick way to tell PHPUnit to re-run this failed test, instead providing the full path manually?
Since PHPUnit 7.3, you can cache the results of your tests, then order your tests by defects.
In phpunit.xml, enable cacheResults
:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit cacheResult="true"
...>
If you don't want to edit your phpunit.xml, you could also run your tests with the --cache-result
flag.
When caching results, PHPUnit will create a .phpunit.result.cache
file after running tests. Make sure to add this file to your global gitignore file.
You can run your tests like this to run previously failed tests first:
phpunit --order-by=defects --stop-on-failure
Take a look at the --filter
cli option. You can find an example in the organisation docs
and in the CLI Docs
.
--filter
Only runs tests whose name matches the given pattern. The pattern can be either the name of a single test or a regular expression that matches multiple test names.
Assume your run phpunit Tests/
and Tests/Stuff/ThatOneTestClassAgain::testThisWorks
fails:
your options are:
phpunit --filter ThatOneTestClassAgain
and
phpunit --filter testThisWorks
or most other strings that somehow make sense
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With