“没有关于每次测试覆盖范围的信息。”来自 Sonar 和 Jacoco Ant 构建

2024-04-05

我正在使用 Ant、Jacoco 和 Sonar。当我运行构建时,声纳告诉我“没有有关每个测试覆盖范围的信息”。声纳仪表板有我的覆盖结果,但我无法深入研究它们以查看代码。然而,Jacoco 生成的 HTML 报告确实包含深入到代码中的内容。这是我的报道任务:

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

我的声纳目标如下所示:

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

有谁知道我缺少什么?


看起来您还没有设置“sonar.tests”属性来告诉 Sonar 在哪里可以找到单元测试的源代码。看http://docs.sonarqube.org/display/SONAR/Analysis+Parameters http://docs.sonarqube.org/display/SONAR/Analysis+Parameters.

大卫·雷科登 |声纳源

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

“没有关于每次测试覆盖范围的信息。”来自 Sonar 和 Jacoco Ant 构建 的相关文章

随机推荐