【发布时间】:2020-12-28 16:59:40
【问题描述】:
我将 Jacoco 与我的 Ant 构建集成。当我运行构建时,测试用例成功执行,然后在我的 TEST-com.worker.ManagerTest.xml 中出现以下异常。 当我添加 excludes="*" 时,不会引发错误。但是 jacoco.exec 生成的大小为 1kb,当我运行报告时,什么也没有生成。有人可以告诉我我错过了什么吗?
例外:
下面是 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>
问候, 周六
【问题讨论】:
标签: ant jacoco test-coverage