I need to see on my ant project in SonarQube the junit test .
I’m using SonarQube 7.8 and sonar-scanner-3.3.0.1492-windows. Below my Build.xml :
<path id="build.lib">
<fileset dir="lib" />
<fileset dir="provided-lib" />
<fileset dir="test-lib" />
</path>
<path id="test.lib">
<fileset dir="lib" />
<fileset dir="provided-lib" />
<fileset dir="test-lib" />
</path>
<target name="ts">
<tstamp>
<format property="build.time" pattern="yyyyMMddHHmm" unit="hour" />
</tstamp>
</target>
<!-- *ADD_CI* -->
<target name="TestisSvil">
<condition property="svil.property">
<isset property="NomeAmbienteLogico"/>
</condition>
<echo>____________________ Property TestisSvil value = "${svil.property}" _________________________</echo>
</target>
<target name="TestisNotSvil">
<condition property="svil.property" >
<not>
<isset property="NomeAmbienteLogico"/>
</not>
</condition>
<echo>_________________ Property TestisNotSvil value = "${svil.property}" ______________________</echo>
</target>
<!-- *END_CI* -->
<target name="all_task">
<antcall target="init_clean"/>
<antcall target="frontend"/>
<antcall target="ear"/>
<antcall target="ear_test"/>
<antcall target="unit_test"/>
<!--<antcall target="final_clean"/> -->
</target>
<target name="init_clean">
<delete dir="target" />
</target>
<!-- processo @...@ nei file di webportaldir -->
<target name="frontend" depends="ts">
<copy todir="${web_portal_dir}">
<fileset dir="${path_web_app}/portalMyProj" />
<!-- <cutdirsmapper dirs="1" />-->
<filterset>
<filter token="versione" value="${build.time}" />
<filter token="acronimo" value="${ant.project.name}" />
</filterset>
</copy>
</target>
<target name="ear" if="svil.property" depends="ts,frontend, TestisNotSvil">
<echo>____________________ ear start _________________________</echo>
<delete dir="${path_dist}" />
<mkdir dir="${path_dist}" />
<mkdir dir="${path_bin}" />
<mkdir dir="${path_lib}" />
<echo file="${path_bin}/versione.txt" append="false">${build.time}</echo>
<javac
encoding="UTF-8"
debug="yes"
includeantruntime="no"
classpathref="build.lib"
srcdir="${path_main_src}"
destdir="${path_bin}"
target="1.7"
source="1.7">
<exclude name="${path_main_rsc}/*Test.java"/>
</javac>
<copy todir="${path_bin}">
<fileset dir="${path_main_rsc}" />
</copy>
<copy todir="${path_lib}">
<fileset dir="lib" includes="**/*" />
</copy>
<zip destfile="${path_target}/${ant.project.name}.war" basedir="${path_dist}" compress="yes" includes="*/**" />
<delete dir="${ear_portal_dir}" includes="*.ear" />
<copy todir="${ear_portal_dir}" file="application-ear.xml" />
<replace casesensitive="true" file="${ear_portal_dir}/application-ear.xml" token="@acronimo@" value="${ant.project.name}" />
<ear destfile="${ear_portal_dir}/${ant.project.name}.ear" appxml="${ear_portal_dir}/application-ear.xml">
<fileset dir="${path_target}" includes="${ant.project.name}.war" />
</ear>
<delete file="${path_target}/${ant.project.name}.war" />
<delete file="${path_target}/${ear_portal_dir}/application-ear.xml" />
</target>
<target name="ear_test" if="svil.property" depends="ts,frontend, TestisSvil">
<echo>____________________ ear_test start _________________________</echo>
<delete dir="${path_dist}" />
<mkdir dir="${path_dist}" />
<mkdir dir="${path_bin}" />
<mkdir dir="${path_lib}" />
<echo file="${path_bin}/versione.txt" append="false">${build.time}</echo>
<javac
encoding="UTF-8"
debug="yes"
includeantruntime="no"
classpathref="build.lib"
srcdir="${path_main_src}:${path_tst_src}"
destdir="${path_bin}"
target="1.7"
source="1.7">
</javac>
<copy todir="${path_bin}">
<fileset dir="${path_main_rsc}" />
<fileset dir="${path_tst_rsc}" />
</copy>
<copy todir="${path_lib}">
<fileset dir="lib" includes="**/*" />
</copy>
<zip destfile="${path_target}/${ant.project.name}.war" basedir="${path_dist}" compress="yes" includes="*/**" />
<delete dir="${ear_portal_dir}" includes="*.ear" />
<copy todir="${ear_portal_dir}" file="application-ear.xml" />
<replace casesensitive="true" file="${ear_portal_dir}/application-ear.xml" token="@acronimo@" value="${ant.project.name}" />
<ear destfile="${ear_portal_dir}/${ant.project.name}.ear" appxml="${ear_portal_dir}/application-ear.xml">
<fileset dir="target" includes="${ant.project.name}.war" />
</ear>
<delete file="${path_target}/${ant.project.name}.war" />
<delete file="${path_target}/${ear_portal_dir}/application-ear.xml" />
</target>
<target name="unit_test" if="svil.property" depends="TestisSvil">
<echo>____________________ unit_test start _________________________</echo>
<delete dir="${path_test_classes}"/>
<mkdir dir="${path_test_classes}"/>
<delete dir="${path_classes}"/>
<mkdir dir="${path_classes}"/>
<delete dir="${path_reports_junit}"/>
<mkdir dir="${path_reports_junit}"/>
<delete dir="${path_reports_jacoco}"/>
<mkdir dir="${path_reports_jacoco}"/>
<copy todir="${path_test_classes}">
<fileset dir="${path_bin_tst}" >
<include name="**/*Test.class"/>
</fileset>
</copy>
<copy todir="${path_classes}">
<fileset dir="${path_bin_tst}" >
<include name="**/*Test.class"/>
</fileset>
</copy>
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="${ant.home}/lib/jacocoant.jar" />
</taskdef>
<jacoco:coverage destfile="${path_reports_jacoco}/jacoco.exec" xmlns:jacoco="antlib:org.jacoco.ant">
<junit fork="yes" forkmode="once" haltonfailure="no" showoutput="no"
printsummary="yes" errorProperty="test.failed"
failureProperty="test.failed">
<formatter type="plain" usefile="true"/>
<formatter type="xml" usefile="true"/>
<classpath>
<pathelement location="${path_bin}"/>
<path refid="test.lib"/>
</classpath>
<batchtest fork="yes" todir="${path_reports_junit}">
<fileset dir="${path_bin}">
<include name="**/*Test.class"/>
</fileset>
</batchtest>
</junit>
</jacoco:coverage>
<junitreport todir="${path_reports_junit}">
<fileset dir="${path_reports_junit}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${path_reports_junit}"/>
</junitreport>
<condition property="msg" value="one or more unit tests failed"
else="unit tests all passed">
<isset property="test.failed" />
</condition>
<echo message="unit tests: "${msg}" ___" />
<jacoco:report xmlns:jacoco="antlib:org.jacoco.ant">
<executiondata>
<file file="${path_reports_jacoco}/jacoco.exec"/>
</executiondata>
<structure name="JaCoCo MyProj ">
<classfiles>
<fileset dir="${path_classes}"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${path_classes}"/>
</sourcefiles>
</structure>
<html destdir="${path_reports_jacoco}"/>
</jacoco:report>
<echo>____________________ unit_test end _________________________</echo>
</target>
<target name="final_clean">
<delete dir="target" />
</target>
---------------------------- Sonar properties ----------------
- sonar.analysis.acronimo=AAAAA
- sonar.analysis.ambiente=svil
- sonar.analysis.branch=dddd
- sonar.analysis.project=test1
- sonar.analysis.rcodeprescript=0
- sonar.analysis.scmtool=CCC
- sonar.analysis.timestamp=12334444
- sonar.analysis.version=v1
- sonar.coverage.exclusions=Sviluppo_Application_DD/MyProj_SRC/SRC/MyProj/**/dto/**
- sonar.coverage.jacoco.xmlReportPaths=Sviluppo_Application_DD/MyProj_SRC/SRC/MyProj/target/reports/jacoco/jacoco.xml
- sonar.exclusions=Sviluppo_Application_DD/MyProj_SRC/SRC/MyProj/**/src/test/**,Sviluppo_Application_DD/MyProj_SRC/SRC/MyProj/target/**,Sviluppo_Application_DD/MyProj_SRC/SRC/MyProj/target/reports/**,Sviluppo_Application_DD/MyProj_SRC/SRC/MyProj/change-settings/**,Sviluppo_Application_DD/MyProj_SRC/SRC/MyProj/change-settings@tmp/**,Sviluppo_Application_DD/MyProj_SRC/SRC/MyProj/maven/**,Sviluppo_Application_DD/MyProj_SRC/SRC/MyProj/isp-config-env/**
- sonar.host.url=http://XXX
- sonar.java.binaries=Sviluppo_Application_DD/MyProj_SRC/SRC/MyProj/target
- sonar.java.test.binaries=Sviluppo_Application_DD/MyProj_SRC/SRC/MyProj/target/test-classes
- sonar.junit.reportPaths=Sviluppo_Application_DD/MyProj_SRC/SRC/MyProj/target/reports/junit
- sonar.login=******
- sonar.projectBaseDir=C:\SONAR_REPOSITORY\XXXX
- sonar.projectKey=test_rtc1
- sonar.projectName=test_rtc1
- sonar.projectVersion=v1
- sonar.scanner.app=ScannerCli
- sonar.scanner.appVersion=3.3.0.1492
- sonar.scm.disabled=true
- sonar.sourceEncoding=windows-1252
- sonar.sources=Sviluppo_Application_DD/MyProj_SRC/SRC/MyProj
- sonar.tests=Sviluppo_Application_DD/MyProj_SRC/SRC/MyProj/target/reports/junit
- sonar.verbose=true
- sonar.working.directory=C:\SONAR_REPOSITORY\XXXX\.scannerwork
After the Analyss I can see the coverage but not my test Unit:
This is the tree of my project
Can someone help me? Thanks in advance