Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPUnit coverage in Cobertura format

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..

like image 940
Sharath Avatar asked Apr 16 '14 06:04

Sharath


People also ask

What is code coverage PHPUnit?

In computer science, code coverage is a measure used to describe the degree to which the source code of a program is tested by a particular test suite. A program with high code coverage has been more thoroughly tested and has a lower chance of containing software bugs than a program with low code coverage.

What is the PHPUnit XML configuration file used to organize tests?

The beStrictAboutChangesToGlobalState Attribute This attribute configures whether PHPUnit should mark a test as risky when global state is manipulated by the code under test (or the test code).

What is PHPUnit XML file?

PHPUnit uses XML file for configuration. This configuration file can be added to your version control system so all developers get the same output. These settings will help you make sure your tests work the way you want.


1 Answers

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
like image 100
Svemir Brkic Avatar answered Sep 23 '22 07:09

Svemir Brkic