本文介绍了示值误差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文档现场中详细描述的一个概念。 http://www.eclemma.org/jacoco/trunk/doc/classids.html.这是为在同一JVM支持类的多个版本(例如一个应用服务器)的一个关键步骤。

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

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

What can cause different class ids?

  • 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覆盖报告生成器:"捆绑类'code项目报告“做不匹配与执行数据"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 18:22