【问题标题】:phpunit --debug still displays only dotsphpunit --debug 仍然只显示点
【发布时间】:2013-06-08 15:44:21
【问题描述】:

我想查看在 phpunit 运行期间当前执行的测试。

我使用 --debug 参数但仍然只能得到点:

$ phpunit --调试 塞巴斯蒂安伯格曼的 PHPUnit 3.7.19。 从 /home/foo/bar/phpunit.xml 读取的配置 ..S........我..

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>

这可能是什么原因?

【问题讨论】:

  • 你不是在寻找--verbose吗?
  • 你想重新表述这个问题,因为不清楚你想要什么。 (开关列表在这里,顺便说一句:phpunit.de/manual/3.6/en/textui.html
  • @Denis,verbose 在他的 phpunit.xml 中已经是真的了
  • 在 PHPUNIT 4.8.30(以及更高版本,大概)中,--debug 适用于此。
  • 我会这样表述“运行 PHPUnit 测试时如何停止默认的点进度输出?”

标签: php symfony phpunit


【解决方案1】:

你想使用--testdox

phpunit --testdox

【讨论】:

  • 这是正确的答案 - 应该得到更多的支持! (也许其他人曾经是正确的?)
  • --testdox 的问题(至少在我的经验中......)是它不像其他错误那样在测试运行的底部显示错误,所以你必须扫描起来找空[ ]s
  • @SeanJA 如果您跳过了测试,它们也会显示为空[ ],因此使用--testdox 将无法知道哪些测试失败了。
【解决方案2】:

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

您已经注意到 --debug 和 --verbose 没有什么帮助。 (我大部分时间都使用 --verbose,但因为它会在出现问题时告诉我更多信息,而其余时间并不是很冗长。)

这是我的第一次尝试:

phpunit --verbose --tap

我在一个有一些慢速测试的测试套件上进行了尝试。它运行良好,直到测试 21,然后什么都没有,然后几分钟后,测试 22 到 598 一口气出现。我怀疑输出缓冲。这是一个没有此问题的变体,但需要打开两个终端窗口:

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

然后在另一个窗口中:

tail -f tap.log

实际上,它并没有准确地告诉您您想要什么,因为它只报告它正在处理的功能。因此,当您遇到延迟时,您必须等待测试完成才能发现哪个是慢速测试。

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

【讨论】:

  • 关键是在其他系统上--debug 曾经运行良好......但那些是 Magento/EcomDev_PHPUnit,不,我在 Symfony2 上 - 也许它不是直接来自 PHPUnit?不知道...
  • @Darren,“延迟输出”不会被认为是一个错误吗?
  • @Pacerier 我不知道。输出缓冲可能是为了启用一些重要的 phpunit 功能。我认为如果您编写自己的测试侦听器类,那么应该不会有延迟(但如果 startTest 钩子上有延迟,那么这将被视为一个错误)。
  • 这会在v9.5 中产生Unknown option "--tap" 错误
【解决方案3】:

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

printerClass="PHPUnit_TextUI_ResultPrinter"

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

【讨论】:

  • 为了澄清,当我在我的 PHPUnit 配置文件中设置它时,这会阻止默认的点进度,并且只使用配置文件中指定的日志记录。
【解决方案4】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-02
    • 2015-05-16
    • 1970-01-01
    相关资源
    最近更新 更多