简体   繁体   English

EMMA覆盖工具不显示逐行覆盖

[英]EMMA coverage tool not displaying line-by-line coverage

I am using the EMMA tool for code coverage yet despite my best efforts, EMMA is refusing to see the original .java files and generate coverage on a line-by-line basis. 我正在使用EMMA工具进行代码覆盖,尽管我付出了最大的努力,但EMMA拒绝查看原始.java文件并逐行生成覆盖。

We are using ANT to build the code and debug is set to true. 我们使用ANT来构建代码,并将debug设置为true。 I know that EMMA is measuring coverage as the .emma files seem to be generating and merging correctly. 我知道EMMA正在测量覆盖率,因为.emma文件似乎正在生成并正确合并。 The reports are able to present high level method coverage with percentages. 报告能够以百分比呈现高水平的方法覆盖率。

But why won't it see the .java files? 但为什么它不会看到.java文件? All I get is: [source file 'a/b/c/d/e/f/code.java' not found in sourcepath] 我得到的是:[在源路径中找不到源文件'a / b / c / d / e / f / code.java']

Are you setting the sourcepath in your report element? 您是否在report元素中设置了sourcepath

<report>
    <sourcepath>
        <pathelement path="${java.src.dir}" />
    </sourcepath>
    <fileset dir="data">
        <include name="*.emma" />
    </fileset>

    <txt outfile="coverage.txt" />
    <html outfile="coverage.html" />
</report>

Could you post the portion of your build.xml that generates the EMMA reports? 你可以发布生成EMMA报告的build.xml部分吗? Sounds like a report sourcepath issue. 听起来像是一个report sourcepath问题。

report sourcepath should point to your java source. report sourcepath应指向您的java源代码。

See sourcepath in the EMMA reference. 请参阅EMMA参考中的sourcepath This can be a path-like structure , so you can include multiple source directories. 这可以是类似路径的结构 ,因此您可以包含多个源目录。

As always, with ANT: 与往常一样,使用ANT:

  • execute the smallest possible build.xml with -verbose 使用-verbose执行最小的build.xml
  • -debug for even more information. -debug以获取更多信息。

I ran into the same issue. 我遇到了同样的问题。 But found that while setting the sourcepath we need to set to the only directory level not to the java file location. 但是发现在设置sourcepath时我们需要设置为唯一的目录级别而不是java文件位置。 it is similar to the classpath 它类似于类路径

does {java.src.dir} need to point to one specific src directory. {java.src.dir}是否需要指向一个特定的src目录。

This is no one single src directory as I am compiling multiple projects. 这不是一个单独的src目录,因为我正在编译多个项目。 Each with their own build.xml file. 每个都有自己的build.xml文件。

I believe this is the portion that generates all the coverage reports: 我相信这是生成所有报道报告的部分:

  <target name="emma.report" if="use.emma">
   <emma enabled="true">
     <report sourcepath="${test.reports.dir}">
       <!--  collect all EMMA data dumps (metadata and runtime):   --> 
       <infileset dir="${test.data.dir}" includes="*.emma" /> 
       <html outfile="${test.reports.dir}/coverage.html" /> 
     </report>
   </emma>
 </target>

EDIT: I changed the sourcepath to point directly to one of the src directories. 编辑:我将源路径更改为直接指向其中一个src目录。 See if that works. 看看是否有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM