Closed ntantri closed 6 years ago
Hi,
I implemented a similar system without using the -Dcobertura.ignoreTrivial=True
. I created an interface like here : https://github.com/cobertura/cobertura/wiki/Coverage-Annotations
Then, I added the following piece of code in my pom.xml
:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<instrumentation>
<ignoreMethodAnnotations>
<ignoreMethodAnnotation>packageName.nameOfMyInterface</ignoreMethodAnnotation>
</ignoreMethodAnnotations>
</instrumentation>
</configuration>
</plugin>
Then I use, the annotation @CoverageIgnore
before the method I don't want to test.
However, there is an alternative solution, instead of avoiding the test of a getter/setter, make it easier in just couple of lines. For that you can have a look at this library: https://github.com/oshoukry/openpojo
Regards,
Geoffrey
Hi Geoffrey,
Thanks for updating.
But adding @CoverageIgnore
for all the getters and setters might be ideal for us.
And in case of the alternative solution, that is something not fitting us to replace our POJO's with.
Is there any way we can pass that ignoreTrivial and get rid of the test for getters and setters?
Hi @tan31989,
Sorry for this late answer. I never used this flag personnaly, so I don't really know how to do that. I found this: https://stackoverflow.com/questions/9261731/is-there-still-no-solution-for-ignoring-setter-getter-other-trivial-methods-wi . I don't know if it helps.
Hi @galexandre,
Thank you for the feedback, we have tried the above solution and it was not of any help.
We had no other choice but to choose Jacoco's integration.
Regards, Nagaraj
Hi,
We use this current plugin for integration with sonar and are quiet not getting the changes seen to eliminate getter and setter methods of the class when it comes to cobertura.
As explained here for the maven plugin: https://stackoverflow.com/questions/8225888/ignore-methods-in-class-cobertura-maven-plugin
I tried to do the same for sonar plugin using the following option:
Unfortunately this is not ignoring the getter's and setter's for us.
Could you help us to understand what more can be done?
Regards.