ant - 使用 Ant 的 Jacoco 覆盖抛出 java.lang.instrument.IllegalClassFormatException:检测类时出错
问题描述
我将 Jacoco 与我的 Ant 构建集成在一起。当我运行构建时,测试用例成功执行,然后在我的 TEST-com.worker.ManagerTest.xml 中出现以下异常。当我添加 excludes="*" 时,不会引发错误。但是 jacoco.exec 生成的大小为 1kb,当我运行报告时,什么也没有生成。有人可以让我知道我错过了什么吗?
例外:
<![CDATA[java.lang.instrument.IllegalClassFormatException:检测类 com/dataaccess/GenericDao 时出错。在 org.jacoco.agent.rt_6qyg3i.CoverageTransformer.transform(CoverageTransformer.java:69)
下面是 jacoco 构建脚本。
<target name="test" depends="test-compile">
<mkdir dir="${report.dir}" />
<jacoco:coverage destfile="${report.dir}/jacoco.exec" xmlns:jacoco="antlib:org.jacoco.ant" exclclassloader="sun.reflect.DelegatingClassLoader:javassist.Loader">
<junit fork="true" forkmode="once" printsummary="on">
<classpath>
<!--<pathelement location="${basedir}/../../../build/lib/aspectjtools.jar"/>
<pathelement location="${basedir}/../../../build/lib/aspectjrt.jar"/>-->
<pathelement path="${test.path}" />
<pathelement path="${dist.dir}/test/unittest-manager.jar" />
</classpath>
<formatter type="xml" />
<batchtest todir="${report.dir}" fork="yes">
<fileset dir="test">
<include name="**/*Test*" />
</fileset>
</batchtest>
</junit>
</jacoco:coverage>
</target>
<target name="report" depends="test">
<echo message="Generating Jacoco reports..." />
<property name="report.dir.file" value="${report.dir}/jacoco.exec"/>
<jacoco:report>
<executiondata>
<file file="${report.dir.file}"/>
</executiondata>
<structure name="JaCoCo Reports">
<classfiles>
<fileset dir="${dist.dir}/applications/lib/manager.jar">
<include name="**/*.class"/>
</fileset>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${src.dir}">
<include name="**/*.java"/>
</fileset>
</sourcefiles>
</structure>
<html destdir="${report.dir}/coverage"/>
</jacoco:report>
</target>
问候,星期六
解决方案
我使用了最新版本 0.8.7 并且它工作正常。
推荐阅读
- c++ - 为什么不管括号中输入的值有多高,sleep 都不等待?
- c++ - 即使功能已实现,C++ 架构 x86_64 的未定义符号
- php - 如何将数组放在另一个文件上
- python - Zipline-Trader 加拿大日历和自定义 CSV
- docker - Docker 问题:删除绑定安装的卷
- c# - 如何使用 swagger 或 postman 在 c# WebApi 中测试 HttpPostedFileBase 的文件上传
- computer-science - 我怎样才能证明这个 dFa 是最小的?
- c# - 从另一个类(不是 ASP.NET 等)访问 EF DBContext 数据库优先方法
- imacros - iMacros 和 Google Keyword Planner:无法将结果保存到剪贴板
- xml - XML XSLT 使用 SAXON EE10.6 流式传输大型 xml 文件