5

I'm trying to get PHPUnit to stop on failure and to order tests by defect, in order to speed up my dev experience (no pun intended).

Here is what I try: I use "--cache-result --order-by=defects --stop-on-defect" on the command line, and additionally I use a phpunit.xml.dist with these flags:

<?xml version="1.0" encoding="UTF-8"?>

<!-- http://phpunit.de/manual/4.1/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
         backupGlobals="false"
         colors="true"
         bootstrap="app/autoload.php"

         cacheResult                    = "true"
         convertErrorsToExceptions      = "true"
         convertNoticesToExceptions     = "true"
         convertWarningsToExceptions    = "true"
         processIsolation               = "false"
         stopOnFailure                  = "true"
         executionOrder                 = "defects"
         beStrictAboutCoversAnnotation  = "true"
         beStrictAboutOutputDuringTests = "true"
         enforceTimeLimit               = "false"
>
[...]

But still my (second) test run looks like this:

[me@horus server]$ ./vendor/bin/phpunit --cache-result --order-by=defects --stop-on-defect
Runtime:       PHP 7.3.10
Configuration: /home/.../phpunit.xml.dist

PHPUnit 7.5.16 by Sebastian Bergmann and contributors.

S..S...........................................................  63 / 619 ( 10%)
...SSS......................................................... 126 / 619 ( 20%)
............................................................EEE 189 / 619 ( 30%)
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE.....................F

Time: 8.41 minutes, Memory: 483.04 MB

There were 43 errors:

[...]

I can tell it's really using my xml because when I mess up the format, the call to PHPUnit fails. But why are the tests not sorted to start with the first failure ? And why is there a whole line of failures, instead of just a single E ? Shouldn't it stop right after the first E ?

Torque
  • 3,319
  • 2
  • 27
  • 39
  • 1
    may be this topic help to you: https://stackoverflow.com/questions/30037315/how-to-tell-phpunit-to-stop-on-failure – Yelnar Oct 11 '19 at 21:48
  • 1
    Thank you @smashrain but it seems like that topic just advises to do exactly what I did – Torque Oct 13 '19 at 16:31

0 Answers0