示值误差jacoco code覆盖报告生成器:"捆绑类'code项目报告“做不匹配与执行数据" [英] jacoco code coverage report generator showing error : "Classes in bundle 'Code Coverage Report' do no match with execution data"

查看:3615
本文介绍了示值误差jacoco code覆盖报告生成器:"捆绑类'code项目报告“做不匹配与执行数据"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

报告标记:

我用jacoco生成jacoco报告。
我得到这样的错误:

  [jacoco:报告]捆绑类'code项目报告做不匹配与执行数据。报告生成相同的类文件,必须使用在运行时。
[jacoco:报告]类XXXXX执行数据不匹配。
[jacoco:报告]类YYYYY执行数据不匹配。

蚂蚁报告的目标如下:

 <目标名称=报告>
                < jacoco:报告>
                        < executiondata>
                                <文件fil​​e =$ {jacocoexec.dir} / $ {} jacocoexec.filename/>
                        < / executiondata>
                        <! - 类文件和可选的源文件... - >
                        <结构名=code项目报告>
                                <&类文件GT;
                                        <文件集文件=./ JAR / abc.jar/>
                                < /类文件>
                                <来源档案>
                                      <文件集DIR =./code / SRC/>
                                < /来源档案>
                        < /结构>
                        <! - 产生不同格式的报告。 - >
                        < HTML DESTDIR =$ {} jacoco.report.dir/>
                < / jacoco:报告>
        < /目标与GT;

abc.jar 这样产生的是使用 ./code / SRC 而已。那为什么让这样的错误。任何想法?


解决方案

您也越来越涉及到的classID错误。这是在JaCoCo文档现场中详细描述的一个概念。 <一href=\"http://www.eclemma.org/jacoco/trunk/doc/classids.html\">http://www.eclemma.org/jacoco/trunk/doc/classids.html.这是为在同一JVM支持类的多个版本(例如一个应用服务器)的一个关键步骤。

部分复制它的某些部分在这里的知名度。

什么是类标识和如何他们创造?


  

类ID是64位的整数值,例如0x638e104737889183在
  16进制。他们的计算被认为是一个实现细节
  的JaCoCo。目前,IDS与原始的CRC64校验和创建
  类文件。


哪些原因会导致不同的类ID?


  

类ID是完全相同的类文件相同的唯一
  (逐字节)。有几个原因,你可能会得到
  不同的类文件。首先编译Java源文件会导致
  在不同的类文件,如果你使用不同的工具链:



  • 不同的编译器供应商(如Eclipse中主场迎战甲骨文JDK)


  • 不同的编译器版本<​​/ p>


  • 不同的编译器设置(例如调试与非调试)


另外的后处理的类​​文件(模糊处理,AspectJ中,等)通常会改变的类文件。 JaCoCo将工作做好,如果你只是使用相同的类文件运行时,以及进行分析。所以工具链来创建这些类文件无关紧要。

即使文件系统上的类文件相同有可能的是由JaCoCo运行剂看到类是不同反正。当另一个Java代理是代理JaCoCo或特殊的类加载器pre-过程中的类文件之前配置这通常发生。典型的候选人是:


  • 惩戒框架

  • 应用程序服务器

  • 持久性框架

在同一页面涵盖了可能的解决方案。

什么方法可以使处理运行时修改的类?

如果类得到你的设置在运行时修改也有一些解决办法,使JaCoCo反正工作:


  • 如果您使用其他Java代理确保JaCoCo剂,首先在命令行中指定。这样,JaCoCo代理应该看到原来的类文件。

  • 指定的JaCoCo剂classdumpdir选项,并生成报告使用甩类。请注意,只有加载的类将倾,即类不执行都不会出现,在您的报告不包括在内。

  • 您运行测试使用前的离线仪器仪表。这样的类得到由JaCoCo任何仪器运行时修改才能生效。注意,在这种情况下,报告具有与原类,不与仪器化的人来产生。

I am generating jacoco report by using jacoco:report tag. I am getting errors like :

[jacoco:report] Classes in bundle 'Code Coverage Report' do no match with execution data. For report generation the same class files must be used as at runtime.
[jacoco:report] Execution data for class xxxxx does not match.
[jacoco:report] Execution data for class yyyyy does not match.

The ant report target looks like :

<target name="report">
                <jacoco:report>
                        <executiondata>
                                <file file="${jacocoexec.dir}/${jacocoexec.filename}"/>
                        </executiondata>
                        <!-- the class files and optional source files ... -->
                        <structure name="Code Coverage Report">
                                <classfiles>
                                        <fileset file="./jar/abc.jar"/>
                                </classfiles>
                                <sourcefiles>
                                      <fileset dir="./code/src"/>
                                </sourcefiles>
                        </structure>
                        <!-- to produce reports in different formats. -->
                        <html destdir="${jacoco.report.dir}"/>
                </jacoco:report>
        </target>

The abc.jar so generated is by using ./code/src only. Then why is it giving such errors. Any idea?

解决方案

You are getting the error related to classID. This is a concept described in detail at JaCoCo docs-site. http://www.eclemma.org/jacoco/trunk/doc/classids.html. This is a key step for supporting multiple versions of class (an appserver for example) in same JVM.

Copying part some part of it here for visibility.

What are class ids and how are they created?

Class ids are 64-bit integer values, for example 0x638e104737889183 in hex notation. Their calculation is considered an implementation detail of JaCoCo. Currently ids are created with a CRC64 checksum of the raw class file.

What can cause different class ids?

Class ids are identical for the exact same class file only (byte-by-byte). There is a couple of reasons why you might get different class files. First compiling Java source files will result in different class files if you use a different tool chain:

  • Different compiler vendor (e.g. Eclipse vs. Oracle JDK)

  • Different compiler versions

  • Different compiler settings (e.g. debug vs. non-debug)

Also post-processing class files (obfuscation, AspectJ, etc.) will typically change the class files. JaCoCo will work well if you simply use the same class files for runtime as well as for analysis. So the tool chain to create these class files does not matter.

Even if the class files on the file system are the same there is possible that classes seen by the JaCoCo runtime agent are different anyways. This typically happens when another Java agent is configured before the JaCoCo agent or special class loaders pre-process the class files. Typical candidates are:

  • Mocking frameworks
  • Application servers
  • Persistence frameworks

The same page covers possible solutions.

What workarounds exist to deal with runtime-modified classes?

If classes get modified at runtime in your setup there are some workarounds to make JaCoCo work anyways:

  • If you use another Java agent make sure the JaCoCo agent is specified at first in the command line. This way the JaCoCo agent should see the original class files.
  • Specify the classdumpdir option of the JaCoCo agent and use the dumped classes at report generation. Note that only loaded classes will be dumped, i.e. classes not executed at all will not show-up in your report as not covered.
  • Use offline instrumentation before you run your tests. This way classes get instrumented by JaCoCo before any runtime modification can take place. Note that in this case the report has to be generated with the original classes, not with instrumented ones.

这篇关于示值误差jacoco code覆盖报告生成器:&QUOT;捆绑类'code项目报告“做不匹配与执行数据&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆