简体   繁体   中英

Clover and Jacoco give different code coverage results

I just ran a code coverage analysis on my project with Clover and the result is about 60%. I ran the analysis on the same project with Jacoco and the result is about 52%. Is the 8% difference normal? I've been running code coverage analysis with these tools in the past too and the difference is never this huge.

Please note that Clover and JaCoCo are using different code coverage metrics:

  • Clover has method, statement and branch coverage (plus the total coverage metric which is a sum of all three)
  • JaCoCo has method, code block, line, branch and instruction coverage

So you cannot simply put the equality sign between results produced by these two tools. I suggest checking reports side-by-side to find where is the highest difference and next to have a look at code constructs used there, resulting in such difference.

Oh. By the way. Keep in mind that JaCoCo uses byte code instrumentation, which means that it will also instrument synthetic methods created by javac compiler and which are not visible in the source code.

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