Hybris Jacoco Sonar包括allwebtests报告结果

时间:2018-09-13 08:44:18

标签: ant sonarqube jacoco hybris

我正在尝试将Jacoco集成到Hybris中并将报告发送到Sonar。我设法实现了Hybris将报告发送到Sonar的情况,但结果报告中没有包含 ant allwebtests 目标。这是我创建并放入以下路径的 acc-ant-sonar.xml

{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>

我想在此文件中添加目标 jacocoallwebtests ,但是Hybris不包含此类目标。因此,如何将 allwebtests 包含在将发送到Jacoco的{​​{1}}报告中?

1 个答案:

答案 0 :(得分:1)

您可以使用与非Web测试相同的目标来执行Web测试。您只需将testclasses.web设置为true 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>