[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sonar-user
Subject:    Re: [sonar-user] How do I exclude Test modules from the percentage calculation of JaCoCo code covera
From:       David Racodon <david.racodon () sonarsource ! com>
Date:       2012-06-29 13:49:43
Message-ID: CA+O9QaKbqkqUTHpD4+6QeXfbUvPvXDsQbWwHiW68heJzkTEF2g () mail ! gmail ! com
[Download RAW message or body]

Hi Daniel,

Thanks for the information.
One more question: how do you know that "The coverage in the test modules
is measured and added to the overall percentage for code coverage."?

Thank you

Regards,
*
*
*David RACODON | **SonarSource
**Senior Consultant*
http://sonarsource.com



On 29 June 2012 13:23, Daniel Warzecha <danowar2k@googlemail.com> wrote:

> Hello David,
>
> our project started as a multi-module Eclipse plugin project. At first
> it didn't use Maven, and local development still doesn't use Maven.
> When we wanted continuous integration and source code analysis, we
> installed Jenkins and Sonar. As both seemed to work better with Maven
> projects, we "converted" our project to Maven, meaning that we added
> POM's for each module and for the project itself and configured
> Jenkins to use these POM's for managing the project.
>
> Our analysis: Jenkins does a checkout over the various project
> modules, both productive code and test code plugins. It does a Maven
> build of the project, using Surefire to do the unit tests. During this
> first phase, JaCoCo also instruments and analyzes the code and
> generates the report.
> During the second phase, Sonar (integrated into Jenkins via the
> appropriate plugin) begins its code analysis, but when calculating
> code coverage, it uses the report JaCoCo generated earlier.
>
> More precisely, our project POM contains
>
>  <jacoco-maven-version>0.5.6.201201232323</jacoco-maven-version>
>
>  <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
>            <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
>
>  <sonar.jacoco.reportPath>${project.basedir}/../../target/jacoco.exec</sonar.jacoco.reportPath>
>
> and also
>
>                        <plugin>
>                                <groupId>org.jacoco</groupId>
>                                <artifactId>jacoco-maven-plugin</artifactId>
>                                <version>${jacoco-maven-version}</version>
>                                <configuration>
>
>  <destFile>${project.basedir}/../../target/jacoco.exec</destFile>
>                                        <excludes>
>
>  <exclude>**/uni_leipzig/**</exclude>
>
>  <exclude>**/*Test.*</exclude>
>
>  <exclude>org/eclipse/uml2/uml/util/UMLSwitch</exclude>
>                                        </excludes>
>                          </configuration>
>                          <executions>
>                            <execution>
>                              <goals>
>                                <goal>prepare-agent</goal>
>                              </goals>
>                            </execution>
>                          </executions>
>                        </plugin>
>
> God, formatting code in e-mails...I'm sorry if this seems cluttered.
>
> The Sonar version we use is 2.13 .
>
> If any additional info would help you help me, I will gladly provide
> more details.
>
> Thanks in advance,
> Daniel Warzecha
>
> 2012/6/29 David Racodon <david.racodon@sonarsource.com>:
> > Hi Daniel,
> >
> > Just a few question to better understand your context:
> >
> > Your project is not a Maven one but you launch your analysis with the
> Maven
> > bootstrapper, correct?
> > Do you reuse reports that you have generated before or do you make Sonar
> > launch directly JaCoCo?
> > Which version of Sonar do you use?
> >
> > Thank you
> >
> > Regards,
> >
> > David RACODON | SonarSource
> > Senior Consultant
> > http://sonarsource.com
> >
> >
> >
> > On 28 June 2012 11:04, Daniel Warzecha <danowar2k@googlemail.com> wrote:
> >>
> >> Hello,
> >>
> >> we're using a Jenkins/Sonar/JaCoCo combo with a multi-module Eclipse
> >> plugin project.
> >> The tests are separated from the productive code, i.e. the test code
> >> of each productive plugin is in a separate test plugin.
> >>
> >> When analyzing the code with JaCoCo, which is run from the Jenkins
> >> Maven side, the generated report is used by Sonar to display code
> >> coverage.
> >>
> >> Our problem: The code coverage percentage seems to be "wrong". The
> >> coverage in the test modules is measured and added to the overall
> >> percentage for code coverage.
> >> We want to see the coverage for the productive code measured, but not
> >> for the test code.
> >>
> >> How could we make this happen? Exclusions? Options?
> >> And where should we apply the changes? Jenkins Sonar Plugin? The Maven
> >> JaCoCo plugin? In the Sonar settings?
> >>
> >> Best Regards,
> >> Daniel Warzecha
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe from this list, please visit:
> >>
> >>    http://xircles.codehaus.org/manage_email
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

[Attachment #3 (text/html)]

Hi Daniel,<div><br></div><div>Thanks for the information.</div><div>One more \
question: how do you know that &quot;The coverage in the test modules is measured and \
added to the overall percentage for code coverage.&quot;?</div> \
<div><br></div><div>Thank you</div><div><br></div><div>Regards,<br \
clear="all"><div><span style="font-family:arial,sans-serif"><font \
color="#000000"><font face="arial, \
sans-serif"><font><b><br></b></font></font></font></span></div> <div><span \
style="font-family:arial,sans-serif"><font color="#000000"><font face="arial, \
sans-serif"><font><b>David RACODON | </b></font></font></font><font \
color="#cc0000"><font face="arial, sans-serif"><font><b>SonarSource<br> \
</b></font></font></font><i>Senior Consultant</i></span></div><div><span \
style="font-family:arial,sans-serif"><a href="http://sonarsource.com/" \
style="color:rgb(0,101,204)" target="_blank"><font \
color="#cc0000">http://sonarsource.com</font></a></span></div> <br>
<br><br><div class="gmail_quote">On 29 June 2012 13:23, Daniel Warzecha <span \
dir="ltr">&lt;<a href="mailto:danowar2k@googlemail.com" \
target="_blank">danowar2k@googlemail.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"> Hello David,<br>
<br>
our project started as a multi-module Eclipse plugin project. At first<br>
it didn&#39;t use Maven, and local development still doesn&#39;t use Maven.<br>
When we wanted continuous integration and source code analysis, we<br>
installed Jenkins and Sonar. As both seemed to work better with Maven<br>
projects, we &quot;converted&quot; our project to Maven, meaning that we added<br>
POM&#39;s for each module and for the project itself and configured<br>
Jenkins to use these POM&#39;s for managing the project.<br>
<br>
Our analysis: Jenkins does a checkout over the various project<br>
modules, both productive code and test code plugins. It does a Maven<br>
build of the project, using Surefire to do the unit tests. During this<br>
first phase, JaCoCo also instruments and analyzes the code and<br>
generates the report.<br>
During the second phase, Sonar (integrated into Jenkins via the<br>
appropriate plugin) begins its code analysis, but when calculating<br>
code coverage, it uses the report JaCoCo generated earlier.<br>
<br>
More precisely, our project POM contains<br>
                &lt;jacoco-maven-version&gt;0.5.6.201201232323&lt;/jacoco-maven-version&gt;<br>
                
                &lt;sonar.core.codeCoveragePlugin&gt;jacoco&lt;/sonar.core.codeCoveragePlugin&gt;<br>
                
            &lt;sonar.dynamicAnalysis&gt;reuseReports&lt;/sonar.dynamicAnalysis&gt;<br>
                
            &lt;sonar.jacoco.reportPath&gt;${project.basedir}/../../target/jacoco.exec&lt;/sonar.jacoco.reportPath&gt;<br>
 <br>
and also<br>
<br>
                        &lt;plugin&gt;<br>
                                &lt;groupId&gt;org.jacoco&lt;/groupId&gt;<br>
                                \
                &lt;artifactId&gt;jacoco-maven-plugin&lt;/artifactId&gt;<br>
                                \
&lt;version&gt;${jacoco-maven-version}&lt;/version&gt;<br>  &lt;configuration&gt;<br>
                                \
&lt;destFile&gt;${project.basedir}/../../target/jacoco.exec&lt;/destFile&gt;<br>  \
                &lt;excludes&gt;<br>
                                                \
                &lt;exclude&gt;**/uni_leipzig/**&lt;/exclude&gt;<br>
                                                \
                &lt;exclude&gt;**/*Test.*&lt;/exclude&gt;<br>
                                                \
&lt;exclude&gt;org/eclipse/uml2/uml/util/UMLSwitch&lt;/exclude&gt;<br>  \
&lt;/excludes&gt;<br>  &lt;/configuration&gt;<br>
                          &lt;executions&gt;<br>
                            &lt;execution&gt;<br>
                              &lt;goals&gt;<br>
                                &lt;goal&gt;prepare-agent&lt;/goal&gt;<br>
                              &lt;/goals&gt;<br>
                            &lt;/execution&gt;<br>
                          &lt;/executions&gt;<br>
                        &lt;/plugin&gt;<br>
<br>
God, formatting code in e-mails...I&#39;m sorry if this seems cluttered.<br>
<br>
The Sonar version we use is 2.13 .<br>
<br>
If any additional info would help you help me, I will gladly provide<br>
more details.<br>
<br>
Thanks in advance,<br>
Daniel Warzecha<br>
<br>
2012/6/29 David Racodon &lt;<a \
href="mailto:david.racodon@sonarsource.com">david.racodon@sonarsource.com</a>&gt;:<br>
 &gt; Hi Daniel,<br>
&gt;<br>
&gt; Just a few question to better understand your context:<br>
&gt;<br>
&gt; Your project is not a Maven one but you launch your analysis with the Maven<br>
&gt; bootstrapper, correct?<br>
&gt; Do you reuse reports that you have generated before or do you make Sonar<br>
&gt; launch directly JaCoCo?<br>
&gt; Which version of Sonar do you use?<br>
&gt;<br>
&gt; Thank you<br>
&gt;<br>
&gt; Regards,<br>
&gt;<br>
&gt; David RACODON | SonarSource<br>
&gt; Senior Consultant<br>
&gt; <a href="http://sonarsource.com" target="_blank">http://sonarsource.com</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On 28 June 2012 11:04, Daniel Warzecha &lt;<a \
href="mailto:danowar2k@googlemail.com">danowar2k@googlemail.com</a>&gt; wrote:<br> \
&gt;&gt;<br> &gt;&gt; Hello,<br>
&gt;&gt;<br>
&gt;&gt; we&#39;re using a Jenkins/Sonar/JaCoCo combo with a multi-module Eclipse<br>
&gt;&gt; plugin project.<br>
&gt;&gt; The tests are separated from the productive code, i.e. the test code<br>
&gt;&gt; of each productive plugin is in a separate test plugin.<br>
&gt;&gt;<br>
&gt;&gt; When analyzing the code with JaCoCo, which is run from the Jenkins<br>
&gt;&gt; Maven side, the generated report is used by Sonar to display code<br>
&gt;&gt; coverage.<br>
&gt;&gt;<br>
&gt;&gt; Our problem: The code coverage percentage seems to be &quot;wrong&quot;. \
The<br> &gt;&gt; coverage in the test modules is measured and added to the \
overall<br> &gt;&gt; percentage for code coverage.<br>
&gt;&gt; We want to see the coverage for the productive code measured, but not<br>
&gt;&gt; for the test code.<br>
&gt;&gt;<br>
&gt;&gt; How could we make this happen? Exclusions? Options?<br>
&gt;&gt; And where should we apply the changes? Jenkins Sonar Plugin? The Maven<br>
&gt;&gt; JaCoCo plugin? In the Sonar settings?<br>
&gt;&gt;<br>
&gt;&gt; Best Regards,<br>
&gt;&gt; Daniel Warzecha<br>
&gt;&gt;<br>
&gt;&gt; ---------------------------------------------------------------------<br>
&gt;&gt; To unsubscribe from this list, please visit:<br>
&gt;&gt;<br>
&gt;&gt;    <a href="http://xircles.codehaus.org/manage_email" \
target="_blank">http://xircles.codehaus.org/manage_email</a><br> &gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
<br>
---------------------------------------------------------------------<br>
To unsubscribe from this list, please visit:<br>
<br>
    <a href="http://xircles.codehaus.org/manage_email" \
target="_blank">http://xircles.codehaus.org/manage_email</a><br> <br>
<br>
</blockquote></div><br></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic