在一个老问题的帮助下,设法使一切正常运转。
我们开始
this post
这为我们提供了一个使用emma的覆盖率设置示例。但是,似乎我们需要在我们想要获取覆盖率数据的每个插件上强制依赖Emma。
一些谷歌取证让我们
this book excerpt
它相当充分地覆盖了OSGi类加载器层次结构。通过添加
osgi.parentClassloader=app
行到测试运行应用程序的config.ini,我们可以在命令行上指定类路径。该类路径需要包括:
-
伊柯丽斯
startup.jar
-
应用程序使用的JAVA SDK JAR
-
覆盖工具的罐子
当然,我们是通过
<java jar="foo.jar">
Ant任务,它会自动忽略您提供的任何类路径信息,只使用jar。在让艾玛工作之后,我们换上了科贝图拉,我们最后的Ant脚本(略为删节和匿名)看起来像:
<target name="generate.coverage" depends="buckminster.init">
<!-- Generate the classpath. -->
<path id="cobertura.classpath">
<fileset dir="${tasks.dir}/lib/cobertura">
<include name="cobertura.jar" />
<include name="**/*.jar" />
</fileset>
</path>
<taskdef classpathref="cobertura.classpath" resource="tasks.properties" />
<!-- Get ready to run the unit tests app, and delete old coverage data. -->
<unzip src="${test-app.artifact}" dest="${output.dir}" overwrite="true" />
<delete file="${output.dir}/cobertura.ser" />
<!-- Instrument the jars in-place. Make sure to only capture what you want instrumented! -->
<cobertura-instrument datafile="${output.dir}/cobertura.ser">
<fileset dir="${output.dir}/test-app/plugins">
<include name="**/*our.company_*.jar" />
</fileset>
</cobertura-instrument>
<!-- Run the unit test application, by classname rather than by jar. -->
<java fork="true" classname="org.eclipse.equinox.launcher.Main" logerror="true" failonerror="true" maxmemory="1G">
<classpath>
<pathelement location="${output.dir}/test-app/startup.jar" />
<pathelement location="${tasks.dir}/lib/cobertura/cobertura.jar" />
<fileset dir="${tasks.dir}/lib/cobertura">
<include name="**/*.jar" />
</fileset>
<pathelement location="${java.class.path}" />
</classpath>
<sysproperty key="net.sourceforge.cobertura.datafile" file="${output.dir}/cobertura.ser" />
<arg value="-data" />
<arg value="${output.dir}/test-app/workspace" />
<arg value="--formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter:${log.dir}/test-results.xml" />
</java>
<!-- Generate the coverage reports. -->
<cobertura-report format="html" datafile="${output.dir}/cobertura.ser" destdir="${output.dir}/cobertura-report">
<fileset dir="${workspace.dir}/plugins">
<include name="**/*.java" />
</fileset>
</cobertura-report>
</target>
希望这能帮助那些和我们在同一地点的人。