sebastianbergmann / phpcov

TextUI frontend for php-code-coverage
BSD 3-Clause "New" or "Revised" License
223 stars 58 forks source link

Is there a way to turn a Clover XML file to HTML (or something else more readable than XML)? #121

Closed k00ni closed 1 year ago

k00ni commented 1 year ago

I run multiple test suits and therefore have multiple coverage files, which I merge into one using https://github.com/sebastianbergmann/phpcov#merging-exported-php-code-coverage-objects-stored-in-cov-files:

phpcov merge --clover /tmp/clover.xml /tmp/coverage

Is there a way to turn /tmp/clover.xml into a HTML representation or console output or something else more readable than XML?

Note: I checked https://github.com/daison12006013/clover-coverage-to-html already, but it doesn't run on PHP 8.1.

If not, any hints how to achieve that are highly appreciated. Thanks in advance.

sebastianbergmann commented 1 year ago

The idea is to persist code coverage data from multiple runs as PHP (using PHPUnit's --coverage-php option, for instance) and then merge that PHP representation using this tool and generate HTML from the merged data, for instance.

This is shown here.

k00ni commented 1 year ago

Thank you for your quick reply, but this issue is not completed.

I have problems understanding how to achieve the last part (... and generate HTML from the merged data). As I wrote, I have a merged file /tmp/clover.xml. It is the result of running phpcov merge --clover /tmp/clover.xml /tmp/coverage.

I already checked the link you gave me, but I am either blind or not able to understand it. As far as I can tell, phpcov has three commands:

  1. ✔️ phpcov execute - Executing a PHP script and generating code coverage in Clover XML format -- done
  2. ✔️ phpcov merge - Merging exported php-code-coverage objects stored in *.cov files -- done
  3. phpcov patch-coverage- Patch Coverage (It doesn't seem to fit, because Git is involved and it prints something on the console)

None of these seem to create a HTML representation when providing the merged /tmp/clover.xml.


EDIT

Answer: After taking a deep look into the code I found that you can use --html path to achieve HTML reporting after the merge command finished.

Example:

phpcov merge --html ./test/coverage/html /tmp/coverage