Skip to content

CoverageCheckConfigUpgrade

Marc R. Hoffmann edited this page Oct 27, 2016 · 2 revisions

With JaCoCo 0.6.3 the configuration for the Maven coverage check has been redesigned to allow more setup scenarios:

  • Limits not only for coverage ratio, also for absolute number of covered or missed items
  • Checks not only for the total figures of all classes, also on individual packages or classes

The new syntax is documented here including examples:

Migration

So for example if your previous configuration was

<instructionRatio>90</instructionRatio>
<methodRatio>80</methodRatio>

the new one woule be:

<rules>
  <rule>
    <element>BUNDLE</element>
    <limits>
      <limit>
        <counter>INSTRUCTION</counter>
        <value>COVEREDRATIO</value>
        <minimum>0.90</minimum>
      </limit>
      <limit>
        <counter>METHOD</counter>
        <value>COVEREDRATIO</value>
        <minimum>0.80</minimum>
      </limit>
    </limits>
  </rule>
</rules>

You could omit the tag (BUNDLE is default) and the tag (COVEREDRATIO is default):

<rules>
  <rule>
    <limits>
      <limit>
        <counter>INSTRUCTION</counter>
        <minimum>0.90</minimum>
      </limit>
      <limit>
        <counter>METHOD</counter>
        <minimum>0.80</minimum>
      </limit>
    </limits>
  </rule>
</rules>

Percentage Values

Note that the new configuration does not use the percentage notation for ratios (so 80% == 0.80).

Definition of BUNDLE

BUNDLE is a set of classes/packages under analysis. Only with the Ant report task it is possible to split the classes under test into multiple bundles (with the "group" tag). With Maven currently all classes of a module form a bundle (once we get multi-module reports I would prefer to have a bundle per module).