Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cobertura ignoreTrivial for Sonar not reflecting. #14

Closed
ntantri opened this issue Nov 9, 2017 · 4 comments
Closed

Cobertura ignoreTrivial for Sonar not reflecting. #14

ntantri opened this issue Nov 9, 2017 · 4 comments

Comments

@ntantri
Copy link

ntantri commented Nov 9, 2017

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:

mvn cobertura:cobertura -Dcobertura.ignoreTrivial=True sonar:sonar -Dsonar.host.url=###### \
-Dcobertura.report.format=xml -Dsonar.login=${SonarToken} -Dsonar.password=

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.

@galexandre
Copy link
Owner

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

@ntantri
Copy link
Author

ntantri commented Nov 10, 2017

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?

@galexandre
Copy link
Owner

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.

@ntantri
Copy link
Author

ntantri commented Jan 23, 2018

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

@ntantri ntantri closed this as completed Jan 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants