I am running Sonar Java code analysis on RHEL6 machine using Ant. For Integration test analysis I am using JaCoCo plugin for sonar. I have the plugin in my library class path. When I run my Selenium tests, a "jacoco.exec" file is generated (around 1MB for 10 tests). I then activate the Jacoco plugin in my Sonar Ant target and import it to Sonar. Sonar analysis logs say that Jacoco file has been analysed (took around 5000ms). However, My Sonar IT widget displays 0% code coverage. I have successfully got the unit test code coverage by using Cobertura.
My test target:
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="${buildHome}/libs/jacocoant.jar"/>
</taskdef>
<jacoco:coverage xmlns:jacoco="antlib:org.jacoco.ant">
<junit fork="yes" failureproperty="true" forkmode="once" maxmemory="1024m">
<formatter type="xml" />
<classpath refid="buildClasspath" />
<test name="${testName}" todir="${testLogs}" if="testcase" />
<batchtest haltonerror="false" todir="${testLogs}">
<fileset dir="${SeleniumScripts">
<include name="**/*.java" />
</fileset>
</batchtest>
</junit>
</jacoco:coverage>
My Sonar Ant target:
...
<property name="sonar.sources" value="${srcCode" />
<property name="sonar.tests" value="${testCode}" />
<property name="sonar.binaries" value="${srcAndTestBinaries}" />
<property name="sonar.dynamicAnalysis" value="reuseReports"/>
<property name="sonar.surefire.reportsPath" value="${reportsPath}" />
<property name="sonar.core.codeCoveragePlugin" value="jacoco" />
<property name="sonar.jacoco.itReportPath" value="${jacocoCoveragePath}/jacoco.exec" />
<!-- Add the Sonar task -->
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<classpath path="${antLibPath}/sonar-ant-task-1.4.jar" />
</taskdef>
<sonar:sonar key="projectKey" version="1.0" xmlns:sonar="antlib:org.sonar.ant"/>
I have tried to include only "relevant" stuff. I am unsure if the "jacoco:coverage" element is corrent for Selenium tests, but in execution logs it mentions the "agent" so I assume the agent is used here as a proxy too on the Java VM.
I'm stuck, please help :)
Updated Here is part of the Sonar output:
[sonar:sonar] 08:36:15.619 INFO p.PhasesTimeProfiler - Sensor JaCoCoItSensor...
[sonar:sonar] 08:36:15.623 INFO o.s.p.j.JaCoCoPlugin - Analysing [file path omitted]\jacoco.exec
[sonar:sonar] 08:36:17.272 INFO p.PhasesTimeProfiler - Sensor JaCoCoItSensor done: 1653 ms