cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Jacoco Sonar include allwebtests to result report

Former Member
0 Likes
2,079

I'm trying to integrate Jacoco into Hybris and send the report to Sonar. I managed to achieve that Hybris sends report to Sonar, but it doesn't include ant allwebtests in the result report. Here is acc-ant-sonar.xml which I created and put in the following path :

{HYBRIS_CONFIG_FOLDER}/customize/ext-accelerator/acceleratorservices/resources/acceleratorservices/ant/acc-ant-sonar.xml

 <project name="acc.ant.sonar" xmlns:jacoco="antlib:org.jacoco.ant">
     <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
         <classpath path="${ext.acceleratorservices.path}/lib/jacocoant.jar"/>
     </taskdef>
 
 
     <target name="jacocoalltests" description="runs allstests with jacoco attached">
 
         <jacoco:agent property="agentvmparam"
                       append="true"
                       output="file"
                       destfile="${HYBRIS_LOG_DIR}/junit/jacoco.exec"
                 />
 
         <property name="testclasses.packages" value="${testclasses.packages}"/>
         <ant dir="${platformhome}" target="alltests" inheritrefs="false">
             <property name="standalone.javaoptions" value="${agentvmparam} ${standalone.javaoptions}"/>
         </ant>
     </target>
 
     <target name="jacocounittests" description="runs allstests with jacoco attached">
 
         <jacoco:agent property="agentvmparam"
                       destfile="${HYBRIS_LOG_DIR}/junit/jacoco.exec"
         />
 
         <property name="testclasses.packages" value="${testclasses.packages}"/>
         <ant dir="${platformhome}" target="unittests" inheritrefs="false">
             <property name="standalone.javaoptions" value="${agentvmparam} ${standalone.javaoptions}"/>
         </ant>
     </target>
 
     <target name="jacocointegrationtests" description="runs allstests with jacoco attached">
 
         <jacoco:agent property="agentvmparam"
                       destfile="${HYBRIS_LOG_DIR}/junit/jacoco-it.exec"
         />
 
         <property name="testclasses.packages" value="${testclasses.packages}"/>
         <ant dir="${platformhome}" target="integrationtests" inheritrefs="false">
             <property name="standalone.javaoptions" value="${agentvmparam} ${standalone.javaoptions}"/>
         </ant>
     </target>
 
 </project>

I wanted to add target jacocoallwebtests in this file, but Hybris doesn't contain such target. So, how could I include allwebtests to Jacoco report which will be be send to Sonar?

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Likes

You can use the same targets to execute web tests as non web tests. You have only to set testclasses.web to true. Example for jacocoallwebtests:

 <target name="jacocoallwebtests" description="runs allwebtests with jacoco attached">
     <jacoco:agent property="agentvmparam"
                   append="true"
                   output="file"
                   destfile="${HYBRIS_LOG_DIR}/junit/jacoco.exec" />
     <property name="testclasses.packages" value="${testclasses.packages}"/>
     <property name="testclasses.web" value="true"/>
     <ant dir="${platformhome}" target="alltests" inheritrefs="false">
          <property name="standalone.javaoptions"
                    value="${agentvmparam} ${standalone.javaoptions}" />
     </ant>
 </target>