I have several clover.xml reports of different extensions of a projects. I want to combine them into one clover.xml and then create it into a clover html. But i see no way with the phpunit classes PHP_CodeCoverage
, PHP_CodeCoverage_Report_HTML
, PHP_CodeCoverage_Report_Clover
.
None of these classes accept an existing clover.xml. I thought I might be able to work with the methods append and merge of PHP_CodeCoverage
. But that does not accept files.
Years later this issue is still partly unsolved. There is a project by SB that can merge clover files, but it requires php 5.6.
None of the answers above work sufficiently well. Here is a gist of a merge thrown together. Constructive critisism welcome.
Usage:
Posting it here for posterity too:
As jkrnak commented above you cannot simply merge the XML files as there are computed values such as lines covered etc.. that are computed at output time. You need to "merge" while still working with native PHP code. In my case I wanted to capture the coverage of a series of web service calls executed by newman. To do this I set a flag at the beginning of execution which persists across invocations (using a cache) and then also save the PHP_CodeCoverage object in the cache as well. My implementation (in Laravel) looks something like this:
This captures the series of tests in a single coverage object which is then output when I make a call with the "dumpCoverage" flag.
If you are running jenkins or similar include a php script in your Ant build file to merge the files using SimpleXML
An example is here http://kuttler.eu/post/merging-and-splitting-xml-files-with-simplexml/
Then in your post build actions jenkins will use the clover.xml to generate your code coverage