blob: 1415ca282cfced960b6c0150c0bd8e7e6fe75714 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
<?xml version="1.0" encoding="UTF-8"?>
<project name="ant-dynamic-cobertura" default="coverage" basedir=".">
<property name="src.dir" value="src"/>
<property name="lib.dir" value="lib"/>
<property name="lib.cobertura.dir" value="${lib.dir}/cobertura"/>
<property name="build.dir" value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="classes.instrumented.dir" value="${build.dir}/instrumented"/>
<property name="reports.dir" value="reports"/>
<property name="reports.junit.xml.dir" value="${reports.dir}/junit/xml"/>
<property name="reports.junit.html.dir" value="${reports.dir}/junit/html"/>
<property name="reports.cobertura.xml.dir" value="${reports.dir}/cobertura/xml"/>
<property name="reports.cobertura.html.dir" value="${reports.dir}/cobertura/html"/>
<path id="classpath">
<fileset dir="${lib.dir}" includes="*.jar"/>
</path>
<path id="cobertura.classpath">
<fileset dir="${lib.cobertura.dir}">
<include name="*.jar" />
</fileset>
</path>
<taskdef classpathref="cobertura.classpath" resource="tasks.properties"/>
<taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
<classpath>
<path refid="classpath"/>
</classpath>
</taskdef>
<taskdef name="junitreport" classname="org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator">
<classpath>
<path refid="classpath"/>
</classpath>
</taskdef>
<target name="init">
<mkdir dir="${build.dir}" />
<mkdir dir="${classes.dir}" />
<mkdir dir="${classes.instrumented.dir}" />
<mkdir dir="${reports.dir}" />
<mkdir dir="${reports.junit.xml.dir}" />
<mkdir dir="${reports.junit.html.dir}" />
<mkdir dir="${reports.cobertura.xml.dir}" />
<mkdir dir="${reports.cobertura.html.dir}" />
</target>
<target name="compile" depends="init">
<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath" fork="true" debug="true"/>
</target>
<target name="instrument" depends="init,compile">
<!--
Remove the coverage data file and any old instrumentation.
-->
<delete file="cobertura.ser"/>
<delete dir="${classes.instrumented.dir}" />
<cobertura-instrument todir="${classes.instrumented.dir}">
<fileset dir="${classes.dir}">
<!--
Instrument all the application classes, but
don't instrument the test classes.
-->
<include name="**/*.class" />
<exclude name="**/*Test.class" />
</fileset>
</cobertura-instrument>
</target>
<target name="test" depends="init,compile">
<junit fork="yes" dir="${basedir}" failureProperty="test.failed">
<!--
Note the classpath order: instrumented classes are before the
original (uninstrumented) classes. This is important.
-->
<classpath location="${classes.instrumented.dir}" />
<classpath location="${classes.dir}" />
<!--
The instrumented classes reference classes used by the
Cobertura runtime, so Cobertura and its dependencies
must be on your classpath.
-->
<classpath refid="cobertura.classpath" />
<classpath refid="classpath" />
<formatter type="xml" />
<batchtest todir="${reports.junit.xml.dir}">
<fileset dir="${src.dir}">
<include name="**/*Test.java" />
</fileset>
</batchtest>
</junit>
<junitreport todir="${reports.junit.html.dir}">
<fileset dir="${reports.junit.xml.dir}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${reports.junit.html.dir}" />
</junitreport>
</target>
<target name="coverage-report">
<!--
Generate an XML file containing the coverage data using
the "srcdir" attribute.
-->
<cobertura-report srcdir="${src.dir}" destdir="${reports.cobertura.xml.dir}" format="xml" />
</target>
<target name="alternate-coverage-report">
<!--
Generate a series of HTML files containing the coverage
data in a user-readable form using nested source filesets.
-->
<cobertura-report destdir="${reports.cobertura.html.dir}">
<fileset dir="${src.dir}">
<include name="**/*.java"/>
</fileset>
</cobertura-report>
</target>
<target name="clean" description="Remove all files created by the build/test process.">
<delete dir="${build.dir}" />
<delete dir="${instrumented.dir}" />
<delete dir="${reports.dir}" />
<delete file="cobertura.log" />
<delete file="cobertura.ser" />
</target>
<target name="coverage" depends="compile,instrument,test,coverage-report,alternate-coverage-report" description="Compile, instrument ourself, run the tests and generate JUnit and coverage reports."/>
</project>
|