|
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 |
|
Hi Daniel,
Just a few question to better understand your context:
Thank you Regards,
David RACODON | SonarSource
Senior Consultant On 28 June 2012 11:04, Daniel Warzecha <[hidden email]> wrote: Hello, |
|
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 <[hidden email]>: > 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 <[hidden email]> 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 |
|
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 On 29 June 2012 13:23, Daniel Warzecha <[hidden email]> wrote: Hello David, |
|
Hi Daniel,
Did you have a look at the following project sample: https://github.com/SonarSource/sonar-examples/tree/master/projects/code-coverage/ut/ut-maven-multimodule-jacoco-runTests? From what I understood of your use case, it should help you answer it.
Regards,
David RACODON | SonarSource
Senior Consultant On 29 June 2012 15:49, David Racodon <[hidden email]> wrote: Hi Daniel, |
|
Hello,
sorry for being so late with an answer. Work and other stuff... Anyways, I've finally figured out some things using your examples... 1. To exclude all *Test.java files from showing up on the Sonar site, I had to use the project-wide exclusions filter (Configuration->exclusions). This probably excludes the Test files from all Sonar analysis, which is okay. The only problem would be with non-test files named that way, which we don't have and won't have in the future. 2. Excluding the files this way fixes the overall CC percentage. For example, if I had 4 packages, 2x 3.6% coverage and 2x 100% coverage, this would amount to 3.9% global coverage. As those 100% packages were the tests, this lead to false values. Fixing the exclusions fixed the global coverage to 3.6%. 3. My problem stemmed from the fact that I tried too many things at once, leading to me obscuring the solution for myself. 4. I hadn't respected the fact that Jenkins, or rather Maven, didn't delete the old jacoco.exec data in a "mvn clean install", because the exec files were stored in $workspace$/target and not in the appropriate module subdirs. I probably have to add that to my configuration. I still have problems regarding code in packages I want to exclude but can't because packages with code to exclude and those with code to include have the same name. But there's a ticket for excluding source folders open, so... Regards, Daniel Warzecha 2012/7/2 David Racodon <[hidden email]>: > Hi Daniel, > > Did you have a look at the following project sample: > https://github.com/SonarSource/sonar-examples/tree/master/projects/code-coverage/ut/ut-maven-multimodule-jacoco-runTests? > From what I understood of your use case, it should help you answer it. > > Regards, > > David RACODON | SonarSource > Senior Consultant > http://sonarsource.com > > > > On 29 June 2012 15:49, David Racodon <[hidden email]> wrote: >> >> 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 <[hidden email]> 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 <[hidden email]>: >>> > 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 <[hidden email]> >>> > 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 >>> >>> >> > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
Good news!
David RACODON | SonarSource
Senior Consultant On 21 July 2012 14:54, Daniel Warzecha <[hidden email]> wrote: Hello, |
| Powered by Nabble | Edit this page |
