Raible's Wiki
Raible Designs AppFuseHomepage- Korean - Chinese - Italian - Japanese QuickStart Guide User Guide Tutorials Other ApplicationsStruts ResumeSecurity Example Struts Menu
Set your name in
UserPreferences
Referenced by
JSPWiki v2.2.33
Hide Menu |
This is version 1.
It is not the current version, and thus it cannot be edited. Code Coverage - How To for integrating Emma with AppFuse 1.8.1 ant build
#
# Emma http://emma.sourceforge.net
#
emma.version=2.0.5312
emma.dir=${lib.dir}/emma-${emma.version}
emma.jar=${lib.dir}/emma-${emma.version}/emma.jar
<path id="emma.libs" >
<pathelement location="${emma.dir}/emma.jar" />
<pathelement location="${emma.dir}/emma_ant.jar" />
</path>
<path id="all.sources" >
<pathelement path="src/dao" />
<pathelement path="src/service" />
<pathelement path="src/web" />
</path>
<taskdef resource="emma_ant.properties" classpathref="emma.libs" />
<target name="emma" description="turns on EMMA instrumentation/reporting" >
<property name="emma.enabled" value="true" />
<!-- EMMA coverage data output directory: -->
<property name="coverage.dir" value="${basedir}/coverage" />
<!-- EMMA instrumented classes output directory: -->
<property name="out.instr.dir" value="${basedir}/outinstr" />
<mkdir dir="${out.instr.dir}" />
<!-- Filter for classes to instrument -->
<property name="emma.filter" value="org.appfuse.*" />
</target>
<delete dir="${out.instr.dir}"/>
<delete dir="${coverage.dir}"/>
<delete dir="${out.instr.dir}"/>
<emma enabled="${emma.enabled}" >
<instr instrpath="${build.dir}/@{module}/classes"
destdir="${out.instr.dir}/@{module}/classes"
metadatafile="${coverage.dir}/metadata-@{module}.emma"
merge="true"
/>
</emma>
<macrodef name="test-module">
<attribute name="module"/>
<attribute name="additional.src.dirs" default=""/>
<element name="options" optional="yes"/>
<sequential>
<echo level="info">Testing @{module}...</echo>
<mkdir dir="${test.dir}/data"/>
<propertycopy name="testcase" from="@{module}-testcase" silent="true"/>
<!-- Replace tokens in test properties files -->
<copy todir="${test.dir}/@{module}/classes">
<fileset dir="test/@{module}" excludes="**/*.java"/>
<filterset refid="variables.to.replace"/>
</copy>
<junit printsummary="no" forkmode="once" errorProperty="test.failed"
failureProperty="test.failed" fork="${junit.fork}">
<classpath>
<!-- Instrumented classes - must be BEFORE the normal ones -->
<!-- ============================= -->
<pathelement location="${out.instr.dir}/@{module}/classes" />
<pathelement path="@{additional.src.dirs}"/>
<path refid="@{module}.test.classpath"/>
<pathelement location="${build.dir}/@{module}/classes"/>
<pathelement location="${test.dir}/@{module}/classes"/>
<pathelement path="${java.class.path}"/>
<pathelement path="${webapp.target}"/>
<pathelement path="${build.dir}/dao/gen"/>
<!-- For .properties and .xml files -->
<pathelement path="${build.dir}/web/classes"/>
<pathelement path="src/@{module}"/>
<!-- Emma library -->
<!-- ============================= -->
<pathelement location="${emma.jar}" />
</classpath>
<!-- emma-specific jvm parameter -->
<!-- =========================== -->
<jvmarg value="-Demma.coverage.out.file=${coverage.dir}/coverage-@{module}.emma" />
<formatter type="xml"/>
<formatter type="brief" usefile="false"/>
<batchtest todir="${test.dir}/data" if="testcase">
<fileset dir="${test.dir}/@{module}/classes">
<include name="**/*${testcase}*"/>
<exclude name="**/*TestCase.class"/>
</fileset>
</batchtest>
<batchtest todir="${test.dir}/data" unless="testcase">
<fileset dir="${test.dir}/@{module}/classes">
<include name="**/*Test.class*"/>
</fileset>
</batchtest>
</junit>
<!-- emma report task -->
<!-- ================================== -->
<emma enabled="${emma.enabled}" >
<report sourcepathref="all.sources" depth="method" >
<fileset dir="${coverage.dir}" >
<include name="*.emma" />
</fileset>
<html outfile="${coverage.dir}/coverage.html" />
</report>
</emma>
<fail if="test.failed">
Unit tests failed. For error messages, check the log files in
${test.dir}/data or run "ant test-reports"
to generate reports at ${test.dir}/reports.</fail>
</sequential>
</macrodef>
|
||||||