phpunit --debug仍然只显示点

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了phpunit --debug仍然只显示点相关的知识,希望对你有一定的参考价值。

我想看看在phpunit运行期间当前执行了哪个测试。

我使用--debug param但仍然只获得点:

$ phpunit --debug 
PHPUnit 3.7.19 by Sebastian Bergmann.

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

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

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>

这可能是什么原因?

答案

我遇到了同样的问题并通过删除它来解决它:

printerClass="PHPUnit_TextUI_ResultPrinter"

来自phpunit.xml配置文件中基本标记的选项。

另一答案

你想要使用--testdox

phpunit --testdox

另一答案

(回答“如何查看当前正在运行的测试”的问题)

正如你所注意的那样--debug和--verbose没什么帮助。 (我大部分时间都使用--verbose,但因为它在出现问题时会告诉我更多信息,其余时间并不是非常冗长。)

这是我的第一次尝试:

phpunit --verbose --tap

我试用了一个测试套件,它有一些慢速测试。它工作得很漂亮,直到测试21,然后没有,然后几分钟后测试22到598一次出现。我怀疑输出缓冲。这是一个没有此问题的变体,但需要打开两个终端窗口:

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

然后在另一个窗口:

tail -f tap.log

实际上它并没有告诉你你想要什么,因为它只报告它正在处理的功能。所以,当你得到延迟时,你必须等待测试结束才能发现哪个是慢速测试。

为了获得更多的控制权,请考虑writing your own test listener

另一答案

我找到的最佳解决方案是将记录部分添加到phpunit.xml文件中

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

以上是关于phpunit --debug仍然只显示点的主要内容,如果未能解决你的问题,请参考以下文章

phpunit单元测试

phpunit 抛出未捕获的异常'PHPUnit_Framework_Exception

phpunit在Windows下安装

为啥 phpunit 没有得到 phpunit.xml 中指定的正确 APP_ENV?

无法使用 composer 安装 phpunit 和 phpunit-selenium

phpunit 单元测试