ant - JaCoCo 报告看起来正确,但无法查看源代码

标签 ant code-coverage emma jacoco

我是 JaCoCo 的新手,并试图找出为什么我生成的 html 报告未与我的源链接。

覆盖率数字看起来正确,我可以浏览到每个类,然后浏览到每个方法,但我看不到源代码。我在源文件标签内尝试了许多不同的东西,但没有任何效果。其他人遇到过这个问题吗?这是我的 ant 脚本的片段:

...

   <test name="test.fw.UITestSuite" todir="${logdir}"/>
    </junit>
    </jacoco:coverage>
    <fail if="TestFailed" status="1" message="UI junit test failure detected"/>
    <echo message="${src}"/>
    <jacoco:report>                                
        <executiondata>
            <file file="jacoco.exec"/>
        </executiondata>                            
        <structure name="UI">
            <classfiles>
                <fileset dir="${build}/fw"/>
            </classfiles>
            <sourcefiles encoding="UTF-8">
                <fileset dir="fw" includes="**./*.java"/>
            </sourcefiles>
        </structure>                                
        <html destdir="report"/>                                
    </jacoco:report>
</target>

...

最佳答案

你的fileset定义看起来很奇怪。

包含必须是(第一个 . 放错了位置):

includes="**/*.java

尝试简单地将其指向您的 src 目录的根目录(不需要包含)

<fileset dir="fw"  />

但是 fw 必须是源的根目录,即它包含如下包文件夹:

src
 -org
   -module
     -MyClass1.java
     -MyClass2.java

关于ant - JaCoCo 报告看起来正确,但无法查看源代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10914320/

相关文章:

ant - SONAR - 如何排除在 "sonar.test"下定义的包

GWT 模块 'xyz' 可能需要(重新)编译

visual-studio-2010 - 批量运行VS代码覆盖工具

plugins - 我应该使用哪个 emma-maven-plugin?

android - 使用新的 Google Play API 计算 android 测试覆盖率

war - Emma 检测 WAR 文件

linux - 将带有文件列表的 shell 脚本转换为 ant build.xml

java - 关于执行时在 build.xml 中出现错误

java - Gradle 和 JaCoCo : instrument classes from a separate subproject

tomcat - cobertura 的副作用