Is there a way to set up coverage thresholds using JaCoCo?

801 views
Skip to first unread message

masingleton

unread,
Oct 2, 2012, 2:33:35 PM10/2/12
to jac...@googlegroups.com
I'm currently switching from Emma to JaCoCo as JaCoCo is currently under support. Under Emma using Maven, I could set method, class, and line coverage percentage thresholds in the pom file. If these thresholds were breached, the Maven build would fail. I am looking for similiar functionality in JaCoCo.
 
Emma example:
 
                                                                                                     
 
<plugin>                                                                                                    
 
<groupId>org.codehaus.mojo</groupId>                                                                                                    
 
<artifactId>emma-maven-plugin</artifactId>                                                                                                    
 
<version>1.0-alpha-3</version>                                                                                                    
 
<configuration>                                                                                                    
 
<check>                                                                                                    
   
<classRate>100</classRate>                                                                                                    
   
<methodRate>95</methodRate>                                                                                                    
   
<lineRate>85</lineRate>                                                                                                    
 
</check>                                                                                                    
 
</configuration>                                                                                                    
 
<executions>                                                                                                    
 
<execution>                                                                                                    
   
<phase>verify</phase>                                                                                                    
   
<goals>                                                                                                    
     
<goal>emma</goal>                                                                                                    
   
<goal>check</goal>                                                                                                    
   
</goals>                                                                                                    
 
</execution>                                                                                                    
 
</executions>                                                                                                    
</plugin>                                                                                                    
 
I can't find anything that replaces this in JaCoCo, so I took a guess:
 
                                                           
 
<plugin>                                                          
 
<groupId>org.jacoco</groupId>                                                          
 
<artifactId>jacoco-maven-plugin</artifactId>                                                          
 
<version>0.5.10.201208310627</version>                                                          
 
<configuration>                                                          
 
<check>                                                          
   
<classRate>100</classRate>                                                          
   
<methodRate>100</methodRate>                                                          
   
<lineRate>100</lineRate>                                                          
 
</check>                                                          
 
</configuration>                                                          
 
<executions>                                                          
 
<execution>                                                          
   
<goals>                                                          
   
<goal>prepare-agent</goal>                                                          
   
</goals>                                                          
   
</execution>                                                          
   
<execution>                                                          
   
<id>report</id>                                                          
   
<phase>prepare-package</phase>                                                          
   
<goals>                                                          
   
<goal>report</goal>                                                          
   
</goals>                                                          
 
</execution>                                                          
 
</executions>                                                          
</plugin>                                                          
 
I guessed incorrectly as the Maven build still passes. Is there a way to fail the build using coverage thresholds. Also, are there default coverage thresholds for JaCoCo?
 

Marc R. Hoffmann

unread,
Oct 2, 2012, 5:31:59 PM10/2/12
to jac...@googlegroups.com
Hi,

this feature is not yet supported, but there is a feature request on its
way that should be included in one of the next releases:

https://github.com/jacoco/jacoco/pull/26

Best regards,
-marc
> --
>
>

masingleton

unread,
Oct 3, 2012, 8:38:19 AM10/3/12
to jac...@googlegroups.com
That's unfortunate. Without this functionality, I'll have to stick with Emma until JaCoCo supports it, hopefully in the next release. Thanks for this information.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages