45

I want to see which test is currently executed during a phpunit run.

I use the --debug param but still only get dots:

$ phpunit --debug 
PHPUnit 3.7.19 by Sebastian Bergmann.

Configuration read from /home/foo/bar/phpunit.xml

..S.......I..

contents of phpunit.xml:

<phpunit backupGlobals="true"
     bootstrap="tests/bootstrap.php"
     backupStaticAttributes="false"
     cacheTokens="false"
     colors="true"
     convertErrorsToExceptions="true"
     convertNoticesToExceptions="true"
     convertWarningsToExceptions="true"
     forceCoversAnnotation="false"
     mapTestClassNameToCoveredClassName="false"
     printerClass="PHPUnit_TextUI_ResultPrinter"
     processIsolation="false"
     stopOnError="false"
     stopOnFailure="false"
     stopOnIncomplete="false"
     stopOnSkipped="false"
     testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader"
     strict="false"
     verbose="true">
    <testsuites>
    <testsuite name="foo Tests">
        <directory>./tests</directory>
    </testsuite>
    </testsuites>
    <filter>
    <whitelist addUncoveredFilesFromWhitelist="true">
        <directory suffix=".php">./src</directory>
    </whitelist>
    </filter>
    <logging>
    <log type="coverage-clover" target="./clover.xml"/>
    </logging>
</phpunit>

What can be the reason for this?

Alex
  • 32,506
  • 16
  • 106
  • 171

4 Answers4

91

You want to be using --testdox

phpunit --testdox

Ian Dunn
  • 3,541
  • 6
  • 26
  • 44
neilakapete
  • 1,098
  • 1
  • 7
  • 11
  • 1
    This is the correct answer - and should be upvoted more! (perhaps the others used to be correct?) – Tim Malone Nov 02 '17 at 23:51
  • 3
    The problem with `--testdox` (at least in my experience...) is that it doesn't display the errors at the bottom of the test run like the other ones, so you have to scan up and look for empty `[ ]`s – SeanJA May 24 '18 at 14:40
  • @SeanJA And if you have skipped tests, they are also displayed as empty `[ ]` so using `--testdox` it will be impossible to know which tests failed. – Janne Annala Jul 11 '19 at 12:26
24

(Answering the question of "how to see which test is currently running")

As you've noticed --debug and --verbose are of little help. (I use --verbose most of the time, but because it tells me more information when things go wrong, and isn't really very verbose the rest of the time.)

Here was my first try:

phpunit --verbose --tap

I tried it out on a test suite that has some slow tests. It worked beautifully until test 21, then nothing, then a few minutes later tests 22 to 598 appeared in one go. I suspect output buffering. Here is a variation that does not have this problem, but requires two terminal windows open:

phpunit --verbose --log-tap tap.log

Then in another window:

tail -f tap.log

Actually it doesn't tell you exactly what you want, because it only reports which function it was working on. So, when you get a delay you have to wait for the test to finish to discover which is the slow test.

To get more control consider writing your own test listener.

Darren Cook
  • 27,837
  • 13
  • 117
  • 217
  • 1
    The point is that on other systems `--debug` used to work well ... But those was Magento/EcomDev_PHPUnit, no I am on Symfony2 - maybe it came not directly from PHPUnit? no clue ... – Alex Jun 13 '13 at 09:59
  • @Darren, Wouldn't "delayed output" be considered to be a bug? – Pacerier Aug 21 '15 at 07:07
  • @Pacerier I don't know. Output buffering is probably there to enable some important phpunit feature. I think if you write your own test listener class then there should be no delay (but if there was a delay on the `startTest` hook then that would count as a bug). – Darren Cook Aug 21 '15 at 08:32
  • 2
    This gives a `Unknown option "--tap"` error in `v9.5` – Ian Dunn May 06 '21 at 16:28
14

I had the same problem and resolved it by removing this:

printerClass="PHPUnit_TextUI_ResultPrinter"

from the options on the base tag in the phpunit.xml config file.

b01
  • 4,076
  • 2
  • 30
  • 30
Gerg
  • 172
  • 1
  • 4
  • For clarification, When I set this in my PHPUnit configuration file, this prevents the default dot progress and uses only the logging specified in the configuration file. – b01 Sep 06 '17 at 13:37
9

The best solution I find was to add logging section to your phpunit.xml file

<logging>
    <log type="testdox-text" target="php://stdout"/>
</logging>
Yevgeniy Afanasyev
  • 37,872
  • 26
  • 173
  • 191