Olivier from the JDT/Core team has been working on running the Emma code coverage tool on the JDT/Core test suites to get an idea of their coverage. Here are some steps to get the tool running in your workspace. (Olivier did most of the work... we just put it on the wiki :-) Contents[hide]StepsSetup
Instrumentation
Run the TestsNext you want to run your tests and collect the output. There are 2 ways to get the output file in the correct place. You can do either of the following:
Create the Report
NotesSome notes and things to think of...
build.xmlThese are the contents of the Ant build file that you will be running. <?xml version="1.0" encoding="UTF-8"?> <project name="emma" basedir="../../."> <!-- What project are you testing? --> <property name="project.dir" value="${basedir}/org.eclipse.core.jobs"/> <!-- Where should we output the results?--> <property name="output.dir" value="D:/temp/emma_output"/> <!-- Emma? Where are you? (Emma installation directory)--> <property name='emma.dir' value='D:/downloads/emma-2.0.5312' /> <!-------------------------------------------------------------> <!-- Where are the class files? --> <property name="bin" value="${project.dir}/bin"/> <!-- EMMA distribution directory: --> <path id='emma.lib' > <fileset dir='${emma.dir}' includes='lib/*.jar' /> </path> <taskdef resource='emma_ant.properties' classpathref='emma.lib' /> <!-- Target which instruments the class files --> <target name="instr"> <mkdir dir="${output.dir}"/> <emma> <!-- instrumentation of bin folder --> <instr instrpath="${bin}" mode="overwrite" outfile="${output.dir}/coverage.em"/> </emma> <!-- copy the emma classes into the bin folder --> <unjar dest="${bin}" src="${emma.dir}/lib/emma.jar" overwrite="true"/> </target> <!-- This target copies your source files so they can be used for generation of the reports later. --> <property name="src.dir" value="${output.dir}/src" /> <target name="export-src"> <antcall target="cleanup"/> <mkdir dir="${src.dir}" /> <copy todir="${src.dir}"> <fileset dir="${project.dir}/src"> <include name="**/*.java"/> </fileset> </copy> </target> <!-- Generate the report. --> <target name="report"> <antcall target="export-src"/> <emma> <!-- creating a report --> <report sort="+name,+class,+method,+block" sourcepath="${src.dir}"> <infileset dir="${output.dir}" includes="*.em, *.ec"/> <html outfile="${output.dir}/index.html" depth="method" columns="name,class,method,block,line"/> </report> </emma> </target> <target name="cleanup"> <delete dir="${src.dir}" failonerror="false"/> </target> </project> |
|