I have a small PHP project that uses PHPUnit for unit tests and coverage. I would like to generate the coverage reports in cobertura XML format.
Is there any tool or plugin that I can use to achieve this?
Any help is appreciated..
I have a small PHP project that uses PHPUnit for unit tests and coverage. I would like to generate the coverage reports in cobertura XML format.
Is there any tool or plugin that I can use to achieve this?
Any help is appreciated..
Support for Cobertura format has just been merged to phpunit and phpcov, and it is available in phpunit 9.4
The report can be generated by invoking phpunit with this flag:
phpunit --coverage-cobertura=my-cobertura-coverage.xml
You can configure cobertura support in config file phpunit.xml
.
Here an example, put the following code inside <phpunit/>
tag:
<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>
Note the <cobertura/>
tag in the example.
The XML format for code coverage information logging produced by PHPUnit is loosely based upon the one used by Clover.
© 2022 - 2024 — McMap. All rights reserved.