简体   繁体   中英

JaCoCo exclude packages with 0% coverage dynamically

I am trying to do some parsing on the JaCoCo XML report that gets generated for a range of our tests.

The issue is, for most of them, as of yet we have very small coverage and the XML report is 59MB. I want to optimize by not having the packages with 0% coverage at all in the report so that parsing is more efficient. Different tests have different packages that are covered so I cannot really hard code the packages to be excluded.

So the question is, does JaCoCO have a report generation option where I can specify to not write the information for packages that have 0% coverage?

This looks like a premature optimization, especially that you did not gave measurement of metric that you want to optimize (btw is it memory or performance?). Also IMO 59 MB doesn't look that big nowadays, both in terms of memory consumption and performance. Maybe you should re-consider the way to parse XML rather than content of report. For example there are XML stream parsers, allowing to skip uninteresting parts and to not hold DOM in memory.

Answering on initial question: no, as of today there is no option in JaCoCo to tune content of XML. However maybe you can use CSV report that is much more compact. Also you can write your own report generator using JaCoCo APIs. JaCoCo documentation includes Javadoc as well as some usage examples , including example of generation of report .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM