Ant 尽管满足工作要求,但Cobertura报告覆盖率为0%
是的,这是另一个0%覆盖率的事情。我已检查并确认以下事项: 1) …程序确实正在生成相应的cobertura.ser文件,并且该文件和插入指令的目录的内容已消失,如所示 2) …该“插装”是在Cobertura测试中识别的第一个类路径 3) …这些线路确实正在我的测试套件中进行测试,而且 4) …确实正在创建并写入“插入指令的”目录--我看到了这种情况 奇怪的是,我注意到Ant生成的报告只不过是一系列信息,内容如下:Ant 尽管满足工作要求,但Cobertura报告覆盖率为0%,ant,code-coverage,junit4,cobertura,Ant,Code Coverage,Junit4,Cobertura,是的,这是另一个0%覆盖率的事情。我已检查并确认以下事项: 1) …程序确实正在生成相应的cobertura.ser文件,并且该文件和插入指令的目录的内容已消失,如所示 2) …该“插装”是在Cobertura测试中识别的第一个类路径 3) …这些线路确实正在我的测试套件中进行测试,而且 4) …确实正在创建并写入“插入指令的”目录--我看到了这种情况 奇怪的是,我注意到Ant生成的报告只不过是一系列信息,内容如下: Testcase: pluralizeIt[0] took 0.004 sec
Testcase: pluralizeIt[0] took 0.004 sec
Caused an ERROR
Instruction type does not match stack map in method StringUtil.main([Ljava/lang/String;)V at offset 50
java.lang.VerifyError: Instruction type does not match stack map in method StringUtil.main([Ljava/lang/String;)V at offset 50
at PluralTest.pluralizeIt(PluralTest.java:55)
但是如果我注释掉所有的Cobertura引用和目标,测试运行得很好,Ant报告就成功和失败而言给了我100%的预期
我的build.xml文件在下面…有什么想法吗???谢谢
<?xml version="1.0" encoding="UTF-8"?>
<project name="TestPlurazliation" default="coverage" basedir=".">
<property name="src" location="src" />
<property name="build" location="bin" />
<property name="cobertura" location="/Users/Dauber/Desktop/cobertura-1.9.4.1" />
<property name="instrumented" location="instrumented" />
<property name="coverage.xml" location="coverage-xml" />
<property name="coverage.html" location="coverage-html" />
<path id="cobertura.classpath">
<fileset dir="${cobertura}">
<include name="cobertura.jar" />
<include name="lib/**/*.jar" />
</fileset>
</path>
<taskdef classpathref="cobertura.classpath" resource="tasks.properties" />
<target name="init">
<tstamp />
<mkdir dir="${build}" />
</target>
<target name="compile" depends="init">
<javac srcdir="/Volumes/Junk/Java projects/SE433/TestingPluralization/src" includeantruntime="false" debug="on" destdir="${build}">
<classpath location="/Users/Dauber/Desktop/junit-4.10.jar" />
</javac>
</target>
<target name="PluralizationTest" depends="compile">
<junit printsummary="yes" fork="yes" haltonfailure="yes">
<classpath location="/Users/Dauber/Desktop/junit-4.10.jar" />
<classpath location="${build}" />
<formatter type="plain" />
<test name="PluralTest" />
</junit>
</target>
<target name="instrument" depends="init,compile">
<delete file="cobertura.ser" />
<delete dir="${instrumented}" />
<cobertura-instrument todir="${instrumented}">
<ignore regex="org.apache.log4j.*" />
<fileset dir="bin">
<include name="**/*.class" />
<exclude name="**/*Test*.class" />
</fileset>
</cobertura-instrument>
</target>
<target name="PluralizationTest2" depends="init,compile">
<junit fork="yes">
<classpath location="${instrumented}" />
<classpath location="${build}" />
<classpath location="/Users/Dauber/Desktop/junit-4.10.jar" />
<classpath refid="cobertura.classpath" />
<formatter type="plain" />
<test name="PluralTest" />
</junit>
</target>
<target name="coverage-report-xml">
<cobertura-report srcdir="${src}" destdir="${coverage.xml}" format="xml" />
</target>
<target name="coverage-report-html">
<cobertura-report srcdir="${src}" destdir="${coverage.html}"/>
</target>
<target name="coverage" depends="compile,instrument,PluralizationTest2,coverage-report-xml,coverage-report-html" />
<target name="clean" description="clean up" >
<delete dir="${build}"/>
<delete dir="${instrumented}"/>
</target>
</project>
如果您使用的是JDK 7,则需要添加UseSplitVerifier JVM参数:
<jvmarg value="-XX:-UseSplitVerifier"/>
(注意:我将此添加为评论中的答案,以便其他人可以轻松找到解决方案。)您使用的是java 7吗?cobertura与jdk7一起工作吗?我正在使用jdk7。我不知道这会是一个问题,但现在你提到了,搜索显示这可能是一个巨大的问题…@ScatteredFrog:你做了更多的研究吗?有什么发现吗?是的……因为我使用的是JDK 7,所以我需要添加这个:最重要的是,当我添加它时,我忘记了一个连字符。(哦!!!)很好。您可以将其添加为答案。:
Java热点(TM)64位服务器虚拟机警告:忽略选项UseSplitVerifier;支持已在8.0中删除
。