Sto usando Ant, Jacoco e Sonar. Quando eseguo il mio build Sonar mi dice che "Nessuna informazione sulla copertura per test". e la dashboard di Sonar ha i risultati della mia copertura, ma non riesco a scavare in essi per vedere il codice. Tuttavia, il report HTML generato da Jacoco include drill down nel codice. Questo è il mio compito di copertura:
"Nessuna informazione sulla copertura per test." da Sonar con Jacoco Ant build
<jacoco:coverage destfile="${coverage.output.file}" >
<junit printsummary="on"
errorProperty="test.failed"
failureProperty="test.failed"
haltonfailure="yes"
fork="true">
<formatter type="brief" usefile="false" />
<formatter type="xml" />
<classpath>
<path refid="test.build.class.path"/>
<pathelement location="${test.bin.dir}"/>
</classpath>
<batchtest todir="${results.dir}">
<fileset dir="${test.bin.dir}">
<include name = "**/**/*Test.class"/>
</fileset>
</batchtest>
</junit>
</jacoco:coverage>
<jacoco:report>
<executiondata>
<file file="${coverage.output.file}"/>
</executiondata>
<structure name="${ant.project.name}">
<classfiles>
<fileset dir="${bin.dir}"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${src.dir}"/>
</sourcefiles>
</structure>
<html destdir="${coverage.results.dir}"/>
</jacoco:report>
</target>
E il mio obiettivo Sonar è simile al seguente:
<target name="sonar" depends = "run">
<property name="sonar.jdbc.url" value="..." />
<property name="sonar.jdbc.username" value="...r" />
<property name="sonar.jdbc.password" value="..." />
<property name="sonar.projectKey" value="org.codehaus.sonar:example-java-ant" />
<property name="sonar.projectName" value="${ant.project.name} (ant)" />
<property name="sonar.projectVersion" value="1.0" />
<property name="sonar.language" value="java" />
<property name="sonar.sources" value="${src.dir}" />
<property name="sonar.binaries" value="${bin.dir},${test.bin.dir}" />
<property name="sonar.libraries" value="${lib.dir}/*.jar" />
<property name="sonar.dynamicAnalysis" value="reuseReports" />
<property name="sonar.surefire.reportsPath" value="${results.dir}" />
<property name="sonar.java.coveragePlugin" value="jacoco" />
<property name="sonar.jacoco.reportPath" value="${coverage.output.file}" />
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<classpath>
<fileset dir="${lib.dir}" includes="sonar-ant-task-2.0.jar"/>
</classpath>
</taskdef>
<sonar:sonar />
</target>
Qualcuno sa che cosa mi manca?
Confermo - nel mio caso, questo è stato impostato per testare le fonti, mentre dovrebbe puntare alle classi compilate. –
Ho provato ad aggiungere la proprietà sonar.tests per fare riferimento sia al codice sorgente che al codice byte. Nessuno dei due ha funzionato. Sono ancora convinto di questo. –
Ho lo stesso problema. Penso che questo potrebbe essere un bug con l'attività Ant poiché l'ho fatto usando Sonar Runner e ha funzionato bene, ma le stesse proprietà in Ant falliscono. – rozner