Unit Test Code coverage Reuse

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Unit Test Code coverage Reuse

softwareforums2013
Hi sonar,

I am using jacoco agent for my code coverage. I reuse the report during sonar analysis. So, I am wondering how does this code coverage in sonar dashboard works. Since, my code coverage is very less and it is because we dont write unit test case for all the layer. We write unit test case from service layer.

But when I have jacoco generate my code coverage, I have included all the layers which is one reason i think my code coverage is too low.

So, If i exclude the classes that we dont write unit test case for in jacoco agent. which i am hoping this will increase my code coverage percentage.

So, during sonar analysis when I use option re-use report, will sonar put the same code coverage percentage generated by jacoco? or do I have to exlude in sonar as well those classes that we dont write unit test cases for.
Reply | Threaded
Open this post in threaded view
|

Re: Unit Test Code coverage Reuse

David Racodon-2
Hi,

You have to use the code coverage exclusion property.

Regards,


David RACODON | SonarSource
Senior Consultant

---------------------------------------------
  Sign up to our newsletter here!
---------------------------------------------


On Fri, Feb 7, 2014 at 10:15 PM, softwareforums2013 <[hidden email]> wrote:
Hi sonar,

I am using jacoco agent for my code coverage. I reuse the report during
sonar analysis. So, I am wondering how does this code coverage in sonar
dashboard works. Since, my code coverage is very less and it is because we
dont write unit test case for all the layer. We write unit test case from
service layer.

But when I have jacoco generate my code coverage, I have included all the
layers which is one reason i think my code coverage is too low.

So, If i exclude the classes that we dont write unit test case for in jacoco
agent. which i am hoping this will increase my code coverage percentage.

So, during sonar analysis when I use option re-use report, will sonar put
the same code coverage percentage generated by jacoco? or do I have to
exlude in sonar as well those classes that we dont write unit test cases
for.




--
View this message in context: http://sonarqube.15.x6.nabble.com/Unit-Test-Code-coverage-Reuse-tp5021932.html
Sent from the SonarQube Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Unit Test Code coverage Reuse

softwareforums2013
Hi David,

thank you for your quick response. So, just excluding those files from sonar exclusion setting will solve this issue or do I have to exclude those files in jacoco agent as well.

For example lets say code coverage report using jacoco came to be 5% (without excluding any files)
and I have exluded some files in sonar exlusion setting property .

So, during sonar analysis will the code coverage go up? Since we have excluded some files.
Reply | Threaded
Open this post in threaded view
|

Re: Unit Test Code coverage Reuse

softwareforums2013
In reply to this post by David Racodon-2
Hi David

one more question, so will this apply only for UT or both UT and IT code coverage. I would just like it to apply this setting for UT code coverage.
Reply | Threaded
Open this post in threaded view
|

Re: Unit Test Code coverage Reuse

softwareforums2013
In reply to this post by David Racodon-2
Hi Again,

I dont want to exclude them from violations and other metrics, just from code coverage for Unit Test.
Reply | Threaded
Open this post in threaded view
|

Re: Unit Test Code coverage Reuse

softwareforums2013
In reply to this post by David Racodon-2
Hi

I think the document is updated version for latest sonar. I am using sonar 3.2.1. So, the settings are some what different. And I got the answer for one of my question. There are separte exclusion setting for violation and code coverage, according to the document.

But, I am wondering where would this setting be in sonar 3.2.1 version

This is what I have found on version 3.2.1,

General Setting --> Jaccoco

I see Excludes sonar.jacoco.excludes. (A list of class names that should be excluded from execution analysis)

 Next one Exclusion
Excludes sources from code analysis

I am hoping the one under jacoco is the one that excludes from code coverage only.
Reply | Threaded
Open this post in threaded view
|

Re: Unit Test Code coverage Reuse

David Racodon-2
Hi,

Your version of SonarQube is very old.
You should update to at least version 4.0 to be able to exclude some files from code coverage by unit tests.

Regards,


David RACODON | SonarSource
Senior Consultant

---------------------------------------------
  Sign up to our newsletter here!
---------------------------------------------


On Sat, Feb 8, 2014 at 12:24 AM, softwareforums2013 <[hidden email]> wrote:
Hi

I think the document is updated version for latest sonar. I am using sonar
3.2.1. So, the settings are some what different. And I got the answer for
one of my question. There are separte exclusion setting for violation and
code coverage, according to the document.

But, I am wondering where would this setting be in sonar 3.2.1 version

This is what I have found on version 3.2.1,

General Setting --> Jaccoco

I see Excludes sonar.jacoco.excludes. (A list of class names that should be
excluded from execution analysis)

 Next one Exclusion
Excludes sources from code analysis

I am hoping the one under jacoco is the one that excludes from code coverage
only.



--
View this message in context: http://sonarqube.15.x6.nabble.com/Unit-Test-Code-coverage-Reuse-tp5021932p5021943.html
Sent from the SonarQube Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email