我是Java新手 . 我使用PowerMockito和JUnit测试用例,JaCoCo用于代码覆盖 . 一些谷歌搜索显示,PowerMockito不能与JaCoCo合作,并建议使用离线检测 . 我为JaCoCo检测创建了一个ant任务,在编译时,它抛出以下错误:

java.lang.ExceptionInInitializerError
        at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:99)
        at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:121)
        at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:148)
        at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:168)
        at org.jacoco.core.instr.Instrumenter.instrumentAll(Instrumenter.java:207)

        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Caused by: java.lang.IllegalArgumentException
        at org.objectweb.asm.MethodVisitor.<init>(Unknown Source)
        at org.jacoco.core.internal.flow.MethodProbesVisitor.<init>(MethodProbesVisitor.java:39)
        at org.jacoco.core.internal.flow.MethodProbesVisitor.<init>(MethodProbesVisitor.java:29)
        at org.jacoco.core.internal.flow.ClassProbesAdapter$1.<init>(ClassProbesAdapter.java:26)
        at org.jacoco.core.internal.flow.ClassProbesAdapter.<clinit>(ClassProbesAdapter.java:26)

这是 build.xml 中的条目:

<target name="instrument" depends="test-compile">
      <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
        <classpath path="lib/asm-all-5.1.jar"/>
        <classpath path="lib/jacocoagent.jar"/>
        <classpath path="lib/jacocoreport.jar"/>
        <classpath path="lib/jacococore.jar"/>
        <classpath path="lib/jacocoant.jar"/>
      </taskdef>
      <mkdir dir="${instrument.dir}"/>
      <jacoco:instrument destdir="${instrument.dir}">
        <fileset dir="${test.build.dir}" includes="**/*.class"/>
      </jacoco:instrument>
    </target>

这可能是什么问题?有没有更好的方法来获得测试覆盖率及其报告?