我能够获得已检测的类,但我找不到运行时覆盖率数据。我使用build.xml(ant)
在hudson中获取输出。任何人都可以帮助我...以下是我的build.xml文件...
<path id="classpath.test">
<pathelement location="${dir.dest}/test.jar"/>
<fileset dir="C:\Program Files\Java\jre7\lib\ext">
<include name="**/*.jar"/>
</fileset>
</path>
<path id="emma.lib">
<pathelement location="C:\Program Files\Java\jre7\lib\ext\emma-2.0.5312.jar" />
<pathelement location="C:\Program Files\Java\jre7\lib\ext\emma_ant-2.0.5312.jar" />
</path>
<taskdef resource="emma_ant.properties" classpathref="emma.lib" />
<target name="compile" depends="init,prepare" >
<javac classpathref="classpath.test" debug="on" srcdir="${src.dir}" destdir="${out.dir}" />
<emma enabled="${emma.enabled}" >
<instr instrpathref="run.classpath" destdir="${out.instr.dir}" metadatafile="${coverage.dir}/coverage.emma" merge="true">
<filter excludes="*Test*"/>
</instr>
</emma>
</target>
<target name="run" depends="jar">
<java classpathref="classpath.test" classname="MainArea" fork="true"/>
</target>
<target name="junit" depends="run">
<junit fork="true" haltonfailure="false" printsummary="yes" failureproperty="test.failed">
<classpath refid="classpath.test"/>
<classpath>
<pathelement location="${basedir}/src" />
<pathelement location="${out.instr.dir}" />
<pathelement location="C:\Program Files\Java\jre7\lib\ext\junit-4.10.jar" />
<pathelement location="C:\Program Files\Java\jre7\lib\ext\emma-2.0.5312.jar" />
<pathelement location="C:\Program Files\Java\jre7\lib\ext\emma_ant-2.0.5312.jar" />
</classpath>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
<batchtest todir=".">
<fileset dir="./workspace">
<include name = "MainAreaTest.java"/>
</fileset>
</batchtest>
<jvmarg value="-Demma.coverage.out.file=${coverage.dir}/coverage.emma"/>
<jvmarg value="-Demma.coverage.out.merge=true"/>
</junit>
</target>
<target name="emma.report" depends="junit">
<emma enabled="${emma.enabled}" verbosity="verbose">
<report sourcepath="./workspace" >
<fileset dir="${coverage.dir}" >
<include name="*.emma" />
</fileset>
<txt outfile="${coverage.dir}/coverage.txt"/>
<html outfile="${coverage.dir}/coverage.html"/>
<xml outfile="${coverage.dir}/coverage.xml"/>
</report>
</emma>
</target>
</project>
我得到了这样的输出....
编译:
[javac] Compiling 5 source files to C:\Users\.hudson\jobs\Code_Coverage\out
[instr] processing instrumentation path ...
[instr] instrumentation path processed in 78 ms
[instr] [7 class(es) instrumented, 0 resource(s) copied]
[instr] metadata merged into [C:\Users\.hudson\jobs\Code_Coverage\coverage\coverage.emma] {in 0 ms}
emma.report:
[echo] emma
[report] [EMMA v2.0, build 5312 (2005/06/12 19:32:43)]
[report] input data path:
[report] {
[report] C:\Users\.hudson\jobs\Code_Coverage\coverage\coverage.emma
[report] }
[report] source path:
[report] {
[report] C:\Users\.hudson\jobs\Code_Coverage\workspace
[report] }
[report] processing input file [C:\Users\.hudson\jobs\Code_Coverage\coverage\coverage.emma] ...
[report] loaded 7 metadata entries
[report] 1 file(s) read and merged in 0 ms
[report] nothing to do: no runtime coverage data found in any of the data files
答案 0 :(得分:0)
您还需要包含.ec文件以生成报告。
<emma enabled="${emma.enabled}" verbosity="verbose">
<report sourcepath="./workspace" >
<fileset dir="${coverage.dir}" >
<include name="*.emma" />
<include name="*.ec" />
</fileset>
<txt outfile="${coverage.dir}/coverage.txt"/>
<html outfile="${coverage.dir}/coverage.html"/>
<xml outfile="${coverage.dir}/coverage.xml"/>
</report>