nedbat / coveragepy

The code coverage tool for Python
https://coverage.readthedocs.io
Apache License 2.0
3.01k stars 433 forks source link

XML coverage report in Jacoco format #534

Open nedbat opened 7 years ago

nedbat commented 7 years ago

Originally reported by Vincent Privat (Bitbucket: don_vip, GitHub: Unknown)


It could be great to be able to generate the XML report in Jacoco format instead of Cobertura one.

The rationale behind it is to ease the integration with other tools such as Jenkins Jacoco plugin, which is compatible with Jenkins 2.0 pipelines, whereas Cobertura plugin is not.

The Jacoco XML format is described with a DTD.


nedbat commented 7 years ago

This seems like a good project for a contribution, especially by someone who can verify that the file is being produced correctly.

joshzcold commented 5 years ago

Looking over what would be required to make this feature I found some resources that might help out. Here is bundle that contains an example of a jacoco report and the dtd jacoco.zip Documentation on Jacoco Coverage output jacoco coverage doc Something we are missing is the "INSTRUCTION" count in each of the counter sections.

The smallest unit JaCoCo counts are single Java byte code instructions. Instruction coverage provides information about the amount of code that has been executed or missed. This metric is completely independent from source formatting and always available, even in absence of debug information in the class files.

Is there anyway we can get metrics for instructions or would we have to spoof this counter if we decided to implement the jacoco format?

nedbat commented 3 years ago

Is there anyway we can get metrics for instructions or would we have to spoof this counter if we decided to implement the jacoco format?

I think we'd have to just write zeros for information we don't have, and hope that tools consuming these reports will be OK with that.