4

I have generated coverage reports with cobertura outside of sonar and would like to "reuse" them and import them into Sonar. Is this possible.

Sonar 3.73 Sonar-Runner 2.3

sonar.projectKey=org.me:artifactname
sonar.projectName=Project Name
sonar.projectVersion=1.0
sonar.sources=src/groovy, grails-app
sonar.language=grvy
sonar.sourceEncoding=UTF-8
sonar.tests=test/unit
sonar.dynamicAnalysis=reuseReports
sonar.core.codeCoveragePlugin=cobertura
sonar.cobertura.reportPath=target/test-reports/cobertura/coverage.xml
sonar.surefire.reportsPath=target/test-reports
sonar.grvy.coveragePlugin=cobertura

The coverage.xml file does exist and is in that path. I've checked it 100 times.

The Unit Test success info is filled out in sonar but the Unit Tests Coverage is a dash, and blank.

Everything else is filled in, complexity, lines of code....

Here's part of the output.

15:47:10.837 INFO  - Load module settings
15:47:11.085 INFO  - Quality profile : [name=Sonar way,language=grvy]
15:47:11.103 INFO  - Excluded tests: 
15:47:11.104 INFO  -   **/package-info.java
15:47:11.143 INFO  - Configure Maven plugins
15:47:11.176 INFO  - Compare to previous analysis (2013-12-20)
15:47:11.210 INFO  - Compare over 30 days (2013-11-20, analysis of 2013-12-19 15:41:26.0)
15:47:11.219 INFO  - Compare to previous version
15:47:11.648 INFO  - Base dir: /Users/Shared/Jenkins/Home/jobs/Grails-Sample-Master/workspace
15:47:11.648 INFO  - Working dir: /Users/Shared/Jenkins/Home/jobs/Grails-Sample-Master/workspace/.sonar
15:47:11.648 INFO  - Source dirs: /Users/Shared/Jenkins/Home/jobs/Grails-Sample-Master/workspace/src/groovy
15:47:11.648 INFO  - Source encoding: UTF-8, default locale: en_US
15:47:11.662 INFO  - Sensor GroovySourceImporter...
15:47:11.761 INFO  - Sensor GroovySourceImporter done: 99 ms
15:47:11.761 INFO  - Sensor CpdSensor...
15:47:11.761 INFO  - SonarBridgeEngine is used
15:47:11.763 INFO  - Cross-project analysis disabled
15:47:11.840 INFO  - Sensor CpdSensor done: 79 ms
15:47:11.841 INFO  - Sensor GroovySensor...
15:47:12.855 INFO  - GMetrics completed: 591ms
15:47:12.879 INFO  - Sensor GroovySensor done: 1038 ms
15:47:12.879 INFO  - Sensor Groovy SurefireSensor...
15:47:12.881 INFO  - parsing /Users/Shared/Jenkins/Home/jobs/Grails-Sample-Master/workspace/target/test-reports
15:47:12.978 INFO  - Sensor Groovy SurefireSensor done: 99 ms
15:47:12.978 INFO  - Sensor InitialOpenIssuesSensor...
15:47:12.983 INFO  - Sensor InitialOpenIssuesSensor done: 5 ms
15:47:12.983 INFO  - Sensor ProfileSensor...
15:47:12.993 INFO  - Sensor ProfileSensor done: 10 ms
15:47:12.993 INFO  - Sensor ProfileEventsSensor...
15:47:13.019 INFO  - Sensor ProfileEventsSensor done: 26 ms
15:47:13.019 INFO  - Sensor ProjectLinksSensor...
15:47:13.028 INFO  - Sensor ProjectLinksSensor done: 9 ms
15:47:13.029 INFO  - Sensor VersionEventsSensor...
15:47:13.041 INFO  - Sensor VersionEventsSensor done: 12 ms
15:47:13.041 INFO  - Sensor org.sonar.plugins.artifactsize.ArtifactSizeSensor@52156251...
15:47:13.041 INFO  - The file null does not exist
15:47:13.041 INFO  - Sensor org.sonar.plugins.artifactsize.ArtifactSizeSensor@52156251 done: 0 ms
15:47:13.470 INFO  - Execute decorators...

Thoughts.

Marcin Zajączkowski
  • 4,036
  • 1
  • 32
  • 41
Dave Brunkow
  • 352
  • 6
  • 20
  • 2
    This may be a case described in the following thread: http://forums.gradle.org/gradle/topics/code_coverage_reports_cobertura_jacoco_are_not_being_pushed_to_sonar . A workaround for https://jira.codehaus.org/browse/SONARPLUGINS-2127 would be to use a patched version of Sonar Groovy Plugin from https://github.com/Spantree/sonar-groovy . – Marcin Zajączkowski Dec 21 '13 at 20:34
  • Unfortunately there is no change with their plugin. Someobody has to have this working in a way that's reproducable. – Dave Brunkow Dec 27 '13 at 18:04
  • Are you sure you were using the snapshot version from Spantree repo (copied built -1.0-spantree-SNAPSHOT.jar into your Sonar extensions directory)? Did you noticed a Cobertura Sensor in the logs? If there is no change with that version you could put a comment in SONARPLUGINS-2127 to tell the author that there still something wrong. – Marcin Zajączkowski Dec 28 '13 at 18:30
  • Fresh install of sonar 3.7.4 with the Ecosystem jars 1.4 and sonar-groovy-plugin-1.0-spantree-SNAPSHOT.jar. There are no test results or coverage results. sonar-project.properties had source directories of data.sonar.sources=grails-app/domain,grails-app/conf If I run with data.sonar.sources=grails-app then I get test data (Unit tests success %) but still no coverage (Unit tests coverage). – Dave Brunkow Jan 02 '14 at 18:00
  • Ok, I'm running mvm clean before I ran sonar-runner. Duh. (For those playing along at home, you don't want to clean out the reports after you generate them). Double duh! I have to run grails test-app -coverage -xml, then run sonar-runner. – Dave Brunkow Jan 02 '14 at 18:28

3 Answers3

1

Try using the absolute path for cobetura reportpath properties. For windows box you can try using the below

sonar.cobertura.reportPath=\\target\\test-reports\\cobertura\\coverage.xml

arunics
  • 31
  • 4
0

Try adding this block to your BuildConfig.groovy

coverage {
    xml = true
}
Zeki
  • 5,107
  • 1
  • 20
  • 27
  • The coverage.xml file existed so I don't believe that was the issue. The issue ended up being that before sonar was executed, clean ran and removed the file. – Dave Brunkow Feb 05 '14 at 14:38
0

You need to use the right property key for specifying the coverage xml report path:

sonar.groovy.cobertura.reportPath=target/test-reports/cobertura/coverage.xml
Rahul
  • 44,383
  • 11
  • 84
  • 103