PHPUnit coverage in Cobertura format
Asked Answered
F

3

20

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

Forbidding answered 16/4, 2014 at 6:32 Comment(4)
Have you ever resolved this problem? I would like to generate a coverage report in Cobertura XML format but i didn't find any existing solution.Lujan
No its been a while, and I havent taken a look at it.Forbidding
Any update on this ?Opisthognathous
Maybe this plugin could help you github.com/Soyhuce/phpunit-to-coberturaAdenocarcinoma
S
26

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
Suavity answered 26/9, 2020 at 10:59 Comment(1)
related PR: github.com/sebastianbergmann/php-code-coverage/pull/812Cholecystitis
S
4

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.

Strategist answered 18/8, 2021 at 23:27 Comment(0)
B
-3

The XML format for code coverage information logging produced by PHPUnit is loosely based upon the one used by Clover.

Braynard answered 27/5, 2016 at 9:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.