This was discovered with Clover 2.2.1

We have a build.xml file with the following pseudo-flow:

  • clover-setup
    • // this causes all future compilations to use the clover compiler to instrument the files.
  • compile
    • javac _all_source_
  • test_A
    • javac _unit_test_source_ // yes, this is a subset of all source
    • junit _unit_tests_

  • test_B
    • javac _unit_test_source_ // yes, this is a subset of all source, and redundant with test_A
    • junit _integration_tests_
  • clover-report
    • NO DATA!

By inserting < clover-log / > at the end of test_A and test_B, I figured out what was going on.

  1. after test_A, we have a nice coverage level
  2. but at the end of test_B, we have been reset back to 0

My hypothesis is that there is a bug in Clover that causes it to:

a) wipe out all of the coverage data thus far when new code is compiled.

b) prevent new code from updating the coverage database.

And sure enough, by removing the javac compilation step from test_B, we have an accurate combined coverage report.

Moral of the story:

  1. Do all of your compiling before you run any of your automated tests
  2. < clover-log / > is your friend.