我正在使用 PHPUnit 3.5.14 并且有一套测试覆盖了我的 PHP 应用程序的 100%,不包括带有 //@codeCoverageIgnore[Start|End] 的某些部分。HTML 覆盖率报告显示 100% 的覆盖率。但是当我生成一个 Clover XML 覆盖率报告时,我希望 Jenkins 阅读该报告以强制执行 100% 覆盖率要求,它显示我所有被忽略的代码都没有被覆盖。
例如,我有一个包含 20 个方法的控制器类,其中一个看起来像这样:
// @codeCoverageIgnoreStart
/**
* Gets an instance of Foo. Abstracted for testing.
*
* @param array $options The constructor argument
*
* @return Foo
*/
protected function _getFoo(array $options)
{
return new Foo($options);
}
// @codeCoverageIgnoreEnd
HTML 覆盖率报告显示了涵盖的 20 种方法,其中包括完全忽略的一种:
图:报道摘录
但是 Clover XML 报告显示了 19/20 种方法,没有提到 _getFoo:
<class name="CampaignController" namespace="global" (...)>
<metrics methods="20" coveredmethods="19" conditionals="0" coveredconditionals="0" statements="532" coveredstatements="532" elements="552" coveredelements="551"/>
...
<line num="592" type="stmt" count="1"/>
<line num="593" type="stmt" count="1"/>
<line num="615" type="method" name="createAction" crap="2" count="2"/>
<line num="617" type="stmt" count="2"/>
(顶部的 _getFoo 行是第 596-608 行。)
我的 PHPUnit 配置的日志记录部分如下所示:
<logging>
<log type="coverage-html" target="../public/build/coverage" charset="UTF-8"
yui="true" highlight="true" lowUpperBound="90" highLowerBound="100"/>
<log type="coverage-clover" target="../public/build/test-coverage.xml"/>
</logging>
有没有办法配置 Clover 覆盖率日志条目,或更改我的覆盖率忽略注释,以便 Clover 报告指示 100% 覆盖率以匹配 HTML 报告?