9

I am using Jacoco with Maven builder for my project's code coverage. I have configured rules around maximum missed classes / methods and minimum line coverage failing which maven build fails (sample below).

<rules>
    <rule>
        <element>BUNDLE</element>
        <limits>
            <limit>
                <counter>CLASS</counter>
                <value>MISSEDCOUNT</value>
                <maximum>90</maximum>
            </limit>
        </limits>
    </rule>
</rules>

I am trying to figure out if there is a mechanism using which these rules get automatically updated if more test cases are added (or more methods are covered using same tests).

Let's say I added test cases for 5 more classes, the maximum value is above rule should be changed to 85.

face
  • 1,503
  • 13
  • 27
  • As a result you want your build to fail if anyone ever adds an application class whithout adding (a) test case(s)? – Selaron Dec 04 '18 at 08:22
  • @Selaron - yes, also if 1 developer added test cases for an existing class and missed count threshold automatically lowers, it will ensure no new application class is going in without test cases. – face Dec 04 '18 at 14:18
  • Might be achivable by writing a custom maven Plugin or ant task that gets number of missed and covered classes from jacoco.xml report file. – Selaron Dec 04 '18 at 19:59
  • True, wondering if there is jacoco (or related) plugin out there doing this already. – face Dec 05 '18 at 06:40

1 Answers1

8

I think what you ask for is actually ratcheting support. This is usually achieved through Continuous Integration systems like Jenkins.

There is currently an open ticket (from 2014) to support ratcheting for Jacoco at Jenkins: https://issues.jenkins-ci.org/browse/JENKINS-22018

It seems that cobertura Jenkins plugin already supports ratcheting. So maybe you could use that if you want.

I do not know about other CI solutions and their Jacoco plugins but I hope that this may help you (hopefully you use a CI system).

ngiallelis
  • 190
  • 4
  • Yes, ratcheting support is exactly what I am looking for. We do use jenkins as a CI solution and I will look into cobertura plugin. Thanks! – face Dec 08 '18 at 11:18