Jacoco integration (regression) test not showing coverge results

1,109 views
Skip to first unread message

Harriet Severino

unread,
Feb 14, 2017, 1:51:15 PM2/14/17
to SonarQube
I am running a regression test for a web-app and need to collect code coverage. I followed these steps to setup:

Rebuild the app jar file with jacoco activated and rsync'ed to server

Restarted tomcat using the javaagent:
-javaagent:/foo/sonarqube/jacoco-0.7.8/lib/jacocoagent.jar=output=tcpserver,jmx=true"


Run the reset command
Run the regression test
Run the dump command

I get a file jacoco-client.exec output. It is a bit bigger than the output file from my unit-test maven run. Therefore, I assume I am correct upto this point.

Sync data file (jacoco-client.exec) to sonar-system, using rsync

sonar-project.properties 
# Required metadata
sonar.projectKey=java-sonar-runner-simple
sonar.projectName=FOO Regression Test
sonar.projectVersion=FOO-2.2

# Comma-separated paths to directories with sources (required)
sonar.sources=src

# Language
sonar.language=java

Run sonar-runner

I get the run in sonarqube, but no coverage data is shown. How do I get the coverage data into sonarqube, assuming I collected coverage data.

I run unit tests via the maven plugin and get coverage in sonarqube, so I can get coverage %s.

G. Ann Campbell

unread,
Feb 14, 2017, 2:12:16 PM2/14/17
to SonarQube
Hi,

First, the customary courtesies (Hi, Thx, ...) are appreciated here. :-)

Do you see anything in your analysis log that relates to JaCoCo? I'm looking at a log from one of our internal projects, & I see:

[INFO] Sensor JaCoCoSensor [java]

[INFO] Analysing /home/travis/build/SonarSource/sonar-rule-api/target/jacoco.exec


Also, I don't understand your last sentence
I run unit tests via the maven plugin and get coverage in sonarqube, so I can get coverage %s.
Is this on a separate project?


Ann

Harriet Severino

unread,
Feb 16, 2017, 10:06:40 AM2/16/17
to SonarQube
I have rsync-ed the jacoco-client.exec file from the server under test. 


sonar-runner.properties sets:

sonar.jacoco.itReportPath=target/jacoco-client.exec

# set location of code under test

sonar.sources=/project/src/main/java/com/akamai/cps

# set location of tests

sonar.tests=/project-regression/src/main/java/com/akamai/cps/testing/

sonar.language=java


I run

sonar-runner -Dsonar.host.url=http://fqdn.sonar.server:9000/sonar


In the output I see:

13:49:59.974 INFO  - Sensor SurefireSensor (done) | time=478ms

13:49:59.974 INFO  - Sensor JaCoCoSensor

13:49:59.999 INFO  - No JaCoCo analysis of project coverage can be done since there is no class files.

13:50:00.000 INFO  - Sensor JaCoCoSensor (done) | time=26ms

13:50:00.003 INFO  - Sensor JaCoCoItSensor

13:50:00.009 INFO  - No JaCoCo analysis of project coverage can be done since there is no class files.

13:50:00.010 INFO  - Sensor JaCoCoItSensor (done) | time=7ms

13:50:00.010 INFO  - Sensor JaCoCoOverallSensor

13:50:00.016 INFO  - Analysing /project/target/jacoco.exec

13:50:00.078 INFO  - Analysing /project/target/jacoco-client.exec

13:50:00.138 INFO  - No JaCoCo analysis of project coverage can be done since there is no class files.

13:50:00.139 INFO  - Sensor JaCoCoOverallSensor (done) | time=129ms

13:50:00.139 INFO  - Sensor SCM Sensor


How do I get class files?


I compile the war file in the directory, on this build server, with jacoco activated.

Rsync the war file onto the test server

Restart web tomcat to load the new war file

Send a reset JMX command

run the regression test

Send a dump JMX command

rsync the jacoco-client output file back to the build server.

Run sonar-runner to analyze results

G. Ann Campbell

unread,
Feb 16, 2017, 10:20:19 AM2/16/17
to Harriet Severino, SonarQube
Hi,

As your log indicates, you're not getting your JaCoCo data included in the analysis because you're not providing the .class files to the analysis:

No JaCoCo analysis of project coverage can be done since there is no class files.

Use sonar.java.binaries to point to their location.


Ann



---
G. Ann CAMPBELL | SonarSource
Product Manager

--
You received this message because you are subscribed to a topic in the Google Groups "SonarQube" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonarqube/79xpfauG9I0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonarqube+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/1a20a06f-d234-4e75-9a37-4df0d28a0154%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages