phpunit --debug still displays only dots

倾然丶 夕夏残阳落幕 提交于 2019-12-20 11:52:35

问题


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?


回答1:


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.




回答2:


You want to be using --testdox

phpunit --testdox




回答3:


(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.




回答4:


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

<logging>
    <log type="testdox-text" target="php://stdout"/>
</logging>


来源:https://stackoverflow.com/questions/17067030/phpunit-debug-still-displays-only-dots

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!