我有一个小的PHP项目,使用PHPUnit进行单元测试和覆盖率。我想要生成cobertura XML格式的覆盖率报告。
是否有任何工具或插件可以帮助我实现这一目标?
非常感谢您的帮助。
我有一个小的PHP项目,使用PHPUnit进行单元测试和覆盖率。我想要生成cobertura XML格式的覆盖率报告。
是否有任何工具或插件可以帮助我实现这一目标?
非常感谢您的帮助。
phpunit和phpcov中刚刚合并了对Cobertura格式的支持,这在phpunit 9.4中可用。
可以通过调用带有此标志的phpunit来生成报告:
phpunit --coverage-cobertura=my-cobertura-coverage.xml
您可以在配置文件phpunit.xml
中配置Cobertura支持。
这里是一个示例,在<phpunit/>
标签中添加以下代码:
<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<cobertura outputFile="cobertura.xml"/>
<html outputDirectory="phpunit-html"/>
<text outputFile="php://stdout"/>
</report>
</coverage>
<cobertura/>
标记。