Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there still no solution for ignoring setter/getter (other trivial methods) with the cobertura-maven-plugin?

Did someone find a good solution to ignore trivial methods?
Using some automated testing like Unitils is not really an option, since the code-coverage should not go up if only getters/setters are tested!

Using cobertrua-maven-plugin version 2.5.1:
-) ignore for methods does not work <ignore>com.company.*.set*</ignore>
-) did anyone try to include a patch like http://sourceforge.net/tracker/index.php?func=detail&aid=3010530&group_id=130558&atid=720017 into the maven-plugin?
-) anyone uses a different (better?) test-plugin?

A general ignore for every get/set/is* method is also not really a good way, since these patterns can be used in other methods but simle getter/setters. Also it should be easy to guess trivial getters/setters/constructors.

I know about the question: Ignore methods in class. cobertura maven plugin but since it did not get any relevant answers, I thought I give it another shot.

like image 771
definitely undefinable Avatar asked Feb 13 '12 13:02

definitely undefinable


1 Answers

Since Cobertura 2.0 there is a switch to exclude trivial methods:

[Cobertura Changelog] New --ignoreTrivial switch that tells Cobertura to ignore the following in the coverage report: Getter methods that simply read a class field; Setter methods that set a class field; Constructors that only set class fields and call a super class constructor.

The cobertura-maven-plugin uses Cobertura 2.x since version 2.6 (see release notes). But i have not yet found a way to pass the switch to the maven plugin configuration.


Although there seems to be some confusion about the state of this feature (see this Jira issue), the flag does seem to work with the following configuration:

<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
  <instrumentation>
    <ignoreTrivial>true</ignoreTrivial>                 
  </instrumentation>
</configuration>
like image 178
dwegener Avatar answered Sep 25 '22 14:09

dwegener