blob: fc5db691b6d52c1d9925977c92789e1fc74e1fe9 [file] [log] [blame]
Cedric Beustac981c42010-07-10 10:53:57 -07001<project name="testng" default="all" basedir=".">
Cedric Beustdc0051b2010-07-10 07:59:56 -07002
3 <property file="build.properties"/>
4
Cedric Beust1af58182010-07-10 11:08:51 -07005 <property name="report.dir" value="${test.output.dir}"/>
Cedric Beustdc0051b2010-07-10 07:59:56 -07006 <property name="junit.report.dir" value="${report.dir}/test-tmp"/>
7 <property name="testng.report.dir" value="${report.dir}"/>
8
Cedric Beustc31cd072011-08-03 14:13:37 -07009 <target name="all" depends="prepare,compile,run,reports,done"/>
Cedric Beustdc0051b2010-07-10 07:59:56 -070010
11 <!-- ==================================================================== -->
12 <!-- Compile -->
13 <!-- ==================================================================== -->
14 <path id="compile.cp">
15 <pathelement location="${testng.jar}" />
Cedric Beustd001f392010-12-10 13:45:32 -080016 <fileset dir="${lib.dir}" includes="${guice2.jar}" />
Cedric Beustdc0051b2010-07-10 07:59:56 -070017 </path>
18
19 <target name="env:info">
20 <echo>
21BASEDIR =${basedir}
Cedric Beust1c00c702010-07-10 08:45:25 -070022TEST.DIR =${test.dir}
Cedric Beustdc0051b2010-07-10 07:59:56 -070023TEST.BUILD.DIR =${test.build.dir}
24REPORT.DIR =${report.dir}
25JUNIT.REPORT.DIR =${junit.report.dir}
26TESTNG.REPORT.DIR=${testng.report.dir}
27 </echo>
28 </target>
29
30 <target name="compile" depends="prepare">
31 <echo message=" -- Compiling tests --"/>
32
33 <property name="build.compiler" value="modern"/>
34 <javac debug="true"
35 source="1.5"
36 classpathref="compile.cp"
Cedric Beust1c00c702010-07-10 08:45:25 -070037 srcdir="${test.dir}"
Cedric Beustdc0051b2010-07-10 07:59:56 -070038 destdir="${test.build.dir}"
39 />
40
41 </target>
42
43 <target name="prepare">
44 <tstamp/>
45 <mkdir dir="${test.build.dir}"/>
46 <mkdir dir="${junit.report.dir}"/>
47 <mkdir dir="${testng.report.dir}"/>
48
49 <taskdef name="testng"
50 classname="org.testng.TestNGAntTask"
51 classpath="${build.dir}"/>
52 </target>
53
Cedric Beusta7d7ad32011-06-29 10:24:56 -070054<!--
Cedric Beustafd8e4a2011-06-01 15:33:26 -070055 <property name="cobertura.dir" value="../cobertura-1.9.4.1" />
56
57 <path id="cobertura.classpath">
58 <fileset dir="${cobertura.dir}">
59 <include name="cobertura.jar" />
60 <include name="lib/**/*.jar" />
61 </fileset>
62 </path>
Cedric Beusta7d7ad32011-06-29 10:24:56 -070063-->
Cedric Beustafd8e4a2011-06-01 15:33:26 -070064
Cedric Beusta7d7ad32011-06-29 10:24:56 -070065 <!-- ==================================================================== -->
Cedric Beustdc0051b2010-07-10 07:59:56 -070066 <!-- Run -->
67 <!-- ==================================================================== -->
68
69 <path id="run.cp">
Cedric Beusta7d7ad32011-06-29 10:24:56 -070070<!--
Cedric Beustafd8e4a2011-06-01 15:33:26 -070071 <path location="target/instrumented-classes" />
72 <path refid="cobertura.classpath" />
Cedric Beusta7d7ad32011-06-29 10:24:56 -070073-->
Cedric Beustdc0051b2010-07-10 07:59:56 -070074 <path refid="compile.cp"/>
75 <pathelement location="${test.build.dir}"/>
76 </path>
77
Cedric Beust88154ea2010-07-16 14:34:16 -070078 <target name="run" description="Run tests" depends="compile,copy-resources">
Cedric Beustdc0051b2010-07-10 07:59:56 -070079 <echo message=" -- Running tests --"/>
80 <echo message=" -- ${testng.jar} --" />
81 <testng classpathref="run.cp"
82 outputdir="${testng.report.dir}">
Cedric Beust1c00c702010-07-10 08:45:25 -070083 <xmlfileset dir="${test.resources.dir}" includes="testng.xml"/>
Cedric Beust93b16a32010-07-10 08:38:42 -070084 <jvmarg value="-Dtest.resources.dir=${test.resources.dir}" />
Cedric Beustf2684812011-02-07 15:04:00 -080085 <jvmarg value="-Dsun.io.serialization.extendedDebugInfo=true" />
Cedric Beustdc0051b2010-07-10 07:59:56 -070086 </testng>
87 </target>
88
Cedric Beust88154ea2010-07-16 14:34:16 -070089 <target name="copy-resources" description="Copies resources.">
90 <copy verbose="false"
Cedric Beust6736fec2010-09-06 09:10:28 -070091 file="${src.resources.dir}/testngtasks"
Cedric Beust88154ea2010-07-16 14:34:16 -070092 todir="${build.dir}" />
93 <copy todir="${build.dir}">
nullinc4f6e792010-07-17 17:41:06 -070094 <fileset dir="${src.resources.dir}">
Cedric Beust88154ea2010-07-16 14:34:16 -070095 <exclude name="**/.*" />
96 <exclude name="**/CVS/*" />
97 </fileset>
98 </copy>
99 </target>
100
Cedric Beustdc0051b2010-07-10 07:59:56 -0700101 <target name="run:single" description="Run 1 property file named with the ant property test" depends="compile">
102 <echo message=" -- testng-tests-run1 --"/>
103
104 <testng outputdir="${testng.report.dir}"
105 classpathref="run.cp"
106 useDefaultListeners="false"
Cedric Beust0d58f772010-07-21 14:36:19 -0700107 methods="test.sample.Sample2.method1,test.sample.Sample2.method3"
Cedric Beustdc0051b2010-07-10 07:59:56 -0700108 outputDir="${testng.report.dir}">
109 <reporter classname="org.testng.reporters.XMLReporter">
110 <property name="generateGroupsAttribute" value="true" />
111 </reporter>
Cedric Beust0d58f772010-07-21 14:36:19 -0700112<!--
Cedric Beust1c00c702010-07-10 08:45:25 -0700113 <xmlfileset dir="${test.resources.dir}" includes="testng-single.xml"/>
Cedric Beust0d58f772010-07-21 14:36:19 -0700114 -->
115 </testng>
Cedric Beustdc0051b2010-07-10 07:59:56 -0700116
117 <echo>Report created in ${testng.report.dir}</echo>
118 </target>
119
120 <target name="run:antprop" description="Run a test to see if ant system propertes are passed correctly" depends="compile">
121 <echo message=" -- testng-tests-run-antprop --"/>
122 <property name="syspropset1" value="value 1"/>
123 <property name="syspropset2" value="value 2"/>
124 <propertyset id="propset1">
125 <propertyref name="syspropset1"/>
126 <propertyref name="syspropset2"/>
127 </propertyset>
128
129 <testng outputdir="${testng.report.dir}"
130 classpathref="run.cp">
Cedric Beust1c00c702010-07-10 08:45:25 -0700131 <xmlfileset dir="${test.resources.dir}" includes="testng-single3.xml"/>
Cedric Beustdc0051b2010-07-10 07:59:56 -0700132 <propertyset refid="propset1"/>
133 <sysproperty key="sysprop1" value="value 3"/>
134 </testng>
135 </target>
136
137 <!-- ==================================================================== -->
138 <!-- Run specific configuration -->
139 <!-- ==================================================================== -->
140 <target name="run:conf"
141 if="testng.conf"
142 depends="clean:reports,compile"
143 description="Run specified tests">
144 <echo message=" -- testng-tests-run --"/>
145 <echo message="using: ${testng.conf}.xml"/>
146
147 <testng classpathref="run.cp"
148 outputDir="${testng.report.dir}">
Cedric Beust1c00c702010-07-10 08:45:25 -0700149 <xmlfileset dir="${test.resources.dir}" includes="${testng.conf}.xml"/>
Cedric Beustdc0051b2010-07-10 07:59:56 -0700150 </testng>
151
152 <antcall target="clean.tmp"/>
153 </target>
154
155
156 <!-- ==================================================================== -->
157 <!-- Reports -->
158 <!-- ==================================================================== -->
159
160 <target name="reports">
161 <junitreport todir="${junit.report.dir}">
162 <fileset dir="${testng.report.dir}">
163 <include name="*.xml"/>
164 <exclude name="testng-failed.xml"/>
165 <exclude name="testng-results.xml" />
166 </fileset>
167 <report format="noframes" todir="${junit.report.dir}"/>
168 </junitreport>
169 </target>
170
171
172 <target name="clean.tmp">
Cedric Beust1af58182010-07-10 11:08:51 -0700173 <delete dir="${test.output.dir}"/>
Cedric Beustdc0051b2010-07-10 07:59:56 -0700174 </target>
175
176 <target name="clean:reports">
177 <delete dir="${report.dir}"/>
178 <delete dir="${junit.report.dir}"/>
179 </target>
180
181 <target name="clean" depends="clean.tmp,clean:reports">
182 <echo message=" -- test clean --"/>
183
184 <delete dir="${test.build.dir}"/>
185 </target>
Cedric Beustc31cd072011-08-03 14:13:37 -0700186
187 <target name="done">
188 <echo>Reports can be found in: open ${testng.report.dir}/index.html</echo>
189 </target>
190
Cedric Beustdc0051b2010-07-10 07:59:56 -0700191</project>