Does clover report coverage of failed unit tests also

692 views Asked by At

I am using clover to calculate the code coverage of my unit tests. I am getting a certain percentage with around 64 tests failing. Just wanted to know whether the failed tests are also contributing to the amount of code covered percentage or not?

1

There are 1 answers

0
Marek On

First, please note that Clover records two kinds of code coverage:

  • global coverage - from entire test run, this will always contain code coverage from all tests (and not only tests, also from setUp methods etc)

  • per-test coverage - code coverage is tracked for every test individually

In case of the per-test coverage you can select whether coverage from failed tests should be included or not. You can configure this option for report generation. See:

  • for Ant - the 'clover-report' task, 'current' element, the includeFailedTestCoverage="true|false" attribute
  • for Maven - clover:clover goal, you have to use tag to change the setting

You can also toggle this in IDE (a coloured bar on editor margin will change):

  • in IDEA - View -> Toolbar - enable it, find "Include coverage from passed tests only" button on the tool bar (the one with a green circle and the "OK" label)
  • in Eclipse - Coverage Explorer view, "Include coverage from passed tests only" button

References:

Cheers Marek