Skip to content

Commit

Permalink
EclEmma(JaCoCo)でJUnitのカバレッジを取るようにした。
Browse files Browse the repository at this point in the history
  • Loading branch information
masanobuimai committed Apr 5, 2012
1 parent 69776ac commit 2f1300b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/dest
/.idea/workspace.xml
/.idea/workspace.xml
*.exec
57 changes: 46 additions & 11 deletions build-jenkins.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,55 @@
</target>


<target name="test" depends="compile-test" description="テストの実行">
<target name="test" depends="compile-test" description="テストの実行とカバレッジレポートの作成">
<!-- EclEmma(JaCoCo)の定義 -->
<property name="jacoco.home" value="${tool.dir}/jacoco-0.5.6"/>
<taskdef resource="org/jacoco/ant/antlib.xml">
<classpath path="${jacoco.home}/lib/jacocoant.jar"/>
</taskdef>
<!-- ここまで -->

<delete dir="${result.test.dir}" />
<mkdir dir="${result.test.dir}" />

<junit fork="on" printsummary="on" maxmemory="256m">
<classpath location="${dest.test.dir}" />
<classpath location="${dest.java.dir}" />
<classpath refid="test.classpath" />

<formatter type="xml" />
<batchtest todir="${result.test.dir}">
<fileset dir="${dest.test.dir}" includes="**/*Test.class" />
</batchtest>
</junit>
<coverage>
<junit fork="on" printsummary="on" maxmemory="256m">
<classpath location="${dest.test.dir}" />
<classpath location="${dest.java.dir}" />
<classpath refid="test.classpath" />

<formatter type="xml" />
<batchtest todir="${result.test.dir}">
<fileset dir="${dest.test.dir}" includes="**/*Test.class" />
</batchtest>
</junit>
</coverage>

<report>
<executiondata>
<file file="jacoco.exec"/>
</executiondata>
<structure name="${ant.project.name}">
<classfiles>
<fileset dir="${dest.java.dir}"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${src.java.dir}"/>
</sourcefiles>
</structure>
<xml destfile="${result.dir}/coverage_jacoco.xml" />
<html destdir="${dest.dir}/report/coverage"/>

</report>
<!-- JaCoCoのレポートをEMMA形式に変換する -->
<xslt style="${jacoco.home}/jacoco_to_emma.xslt"
in="${result.dir}/coverage_jacoco.xml"
out="${result.dir}/coverage.xml"
classpath="${jacoco.home}/saxon9he.jar">
<xmlcatalog>
<dtd publicid="-//JACOCO//DTD Report 1.0//EN" location="${jacoco.home}/coverage/report.dtd"/>
</xmlcatalog>
</xslt>
</target>


Expand Down
Binary file added tool/jacoco-0.5.6/saxon9he.jar
Binary file not shown.

0 comments on commit 2f1300b

Please sign in to comment.