【问题标题】:Using phpunit CLI output in a php script在 php 脚本中使用 phpunit CLI 输出
【发布时间】:2012-01-10 15:49:31
【问题描述】:

phpunit 测试的 CLI 输出包含有用的信息,例如:

PHPUnit 3.6.4 by Sebastian Bergmann.
F
Time: 7 seconds, Memory: 5.50Mb
There was 1 failure:
1) testHandler::testItem
Failed asserting that page text contains <itest New Family Name>.

Driver.php:632
testHandler.php:29
S163.php:18
testHandler.php:46

FAILURES!
Tests: 1, Assertions: 97, Failures: 1.

我想通过 php curl 以 POST 的方式将此信息发送到我的测试跟踪软件。

但是我找不到在我的测试类(扩展 PHPUnit_Framework_TestCase)中捕获信息的方法。

任何帮助/想法将不胜感激。

【问题讨论】:

    标签: php phpunit


    【解决方案1】:

    如果您有自定义构建解决方案,最简单的方法似乎是:

    phpunit | curl -X http://url
    

    phpunit 2>&1 > output.txt && cat output.txt | curl -X http://url
    

    或类似的东西。

    如果您使用的是适当的持续集成服务器,请查看 --log-junit--coverage-clover 或其他输出格式,例如 --log-json

    我看不出您有任何理由希望在测试运行时以编程方式获取输出。这似乎是比收获更多的工作。不过,有一些方法可以扩展 PHPUnit 以将其与 bugtrackers 集成。看看PHPUnit_Framework_TestListener

    【讨论】:

      猜你喜欢
      • 2021-10-15
      • 1970-01-01
      • 2010-11-24
      • 2014-10-09
      • 2016-04-09
      • 2012-06-29
      • 2019-05-04
      • 2013-09-08
      • 1970-01-01
      相关资源
      最近更新 更多