【问题标题】:Logging additional custom information in PHPUnit for reports在 PHPUnit 中为报告记录额外的自定义信息
【发布时间】:2012-07-13 10:25:18
【问题描述】:

我正在使用 PHPUnit Selenium 对我的项目进行功能测试。 我正在使用 junit 进行日志记录并使用日志文件来生成报告。以下是phpunit.xml中的日志标签

<phpunit>
 <logging>
  <log type="junit" target="reports/logfile.xml" logIncompleteSkipped="false" />
 </logging>
</phpunit>

然后我使用 logfile.xml 生成报告。

我正在寻找的是记录附加信息的能力(在两种情况下,即在断言的通过/失败中,说明在断言中究竟测试了什么的信息)。

基本上,我想在报告中说明所断言的内容。并且该信息将由测试编写者在测试用例中手动写入以及断言。

assert 函数带有第三个可选参数作为消息,但仅在失​​败时显示。

例如:

<?php
// $accountExists is the dummy variable which wil probably checking in database for the existence of the record
$this->assertEquals(true, $accountExists, 'Expecting for accountExists to be true');
?>

以上将在失败时返回消息,但在测试通过时不返回。

【问题讨论】:

    标签: selenium report reporting phpunit


    【解决方案1】:

    你必须使用

    --printer 命令行参数指向自定义打印机类

    http://www.phpunit.de/manual/3.6/en/extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestListener

    在您的 endTest 函数中,您在 printf 中输入的任何内容都会显示在您的日志文件中。

    【讨论】:

      猜你喜欢
      • 2021-06-02
      • 1970-01-01
      • 2010-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-17
      • 1970-01-01
      相关资源
      最近更新 更多