blob: 3b3485dd9bdc6b048e6bebe65637f304db47542e [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}" />
Lukas Jungmannf5c4b352011-12-30 19:50:29 +010017 <fileset dir="${lib.dir}" includes="${junit.jar}" />
Cedric Beustdc0051b2010-07-10 07:59:56 -070018 </path>
19
20 <target name="env:info">
21 <echo>
22BASEDIR =${basedir}
Cedric Beust1c00c702010-07-10 08:45:25 -070023TEST.DIR =${test.dir}
Cedric Beustdc0051b2010-07-10 07:59:56 -070024TEST.BUILD.DIR =${test.build.dir}
25REPORT.DIR =${report.dir}
26JUNIT.REPORT.DIR =${junit.report.dir}
27TESTNG.REPORT.DIR=${testng.report.dir}
28 </echo>
29 </target>
Lukas Jungmann18763552012-02-01 23:43:46 +010030
Cedric Beustdc0051b2010-07-10 07:59:56 -070031 <target name="compile" depends="prepare">
32 <echo message=" -- Compiling tests --"/>
33
34 <property name="build.compiler" value="modern"/>
35 <javac debug="true"
36 source="1.5"
37 classpathref="compile.cp"
Cedric Beust1c00c702010-07-10 08:45:25 -070038 srcdir="${test.dir}"
Cedric Beustdc0051b2010-07-10 07:59:56 -070039 destdir="${test.build.dir}"
40 />
Lukas Jungmann18763552012-02-01 23:43:46 +010041
Cedric Beustdc0051b2010-07-10 07:59:56 -070042 </target>
43
44 <target name="prepare">
45 <tstamp/>
46 <mkdir dir="${test.build.dir}"/>
47 <mkdir dir="${junit.report.dir}"/>
48 <mkdir dir="${testng.report.dir}"/>
Lukas Jungmann18763552012-02-01 23:43:46 +010049
Cedric Beustdc0051b2010-07-10 07:59:56 -070050 <taskdef name="testng"
51 classname="org.testng.TestNGAntTask"
52 classpath="${build.dir}"/>
53 </target>
54
Cedric Beusta7d7ad32011-06-29 10:24:56 -070055<!--
Cedric Beustafd8e4a2011-06-01 15:33:26 -070056 <property name="cobertura.dir" value="../cobertura-1.9.4.1" />
57
58 <path id="cobertura.classpath">
59 <fileset dir="${cobertura.dir}">
60 <include name="cobertura.jar" />
61 <include name="lib/**/*.jar" />
62 </fileset>
63 </path>
Cedric Beusta7d7ad32011-06-29 10:24:56 -070064-->
Cedric Beustafd8e4a2011-06-01 15:33:26 -070065
Cedric Beusta7d7ad32011-06-29 10:24:56 -070066 <!-- ==================================================================== -->
Cedric Beustdc0051b2010-07-10 07:59:56 -070067 <!-- Run -->
68 <!-- ==================================================================== -->
69
70 <path id="run.cp">
Cedric Beusta7d7ad32011-06-29 10:24:56 -070071<!--
Cedric Beustafd8e4a2011-06-01 15:33:26 -070072 <path location="target/instrumented-classes" />
73 <path refid="cobertura.classpath" />
Cedric Beusta7d7ad32011-06-29 10:24:56 -070074-->
Cedric Beustdc0051b2010-07-10 07:59:56 -070075 <path refid="compile.cp"/>
76 <pathelement location="${test.build.dir}"/>
77 </path>
78
Cedric Beust88154ea2010-07-16 14:34:16 -070079 <target name="run" description="Run tests" depends="compile,copy-resources">
Cedric Beustdc0051b2010-07-10 07:59:56 -070080 <echo message=" -- Running tests --"/>
81 <echo message=" -- ${testng.jar} --" />
82 <testng classpathref="run.cp"
83 outputdir="${testng.report.dir}">
Cedric Beust1c00c702010-07-10 08:45:25 -070084 <xmlfileset dir="${test.resources.dir}" includes="testng.xml"/>
Cedric Beust93b16a32010-07-10 08:38:42 -070085 <jvmarg value="-Dtest.resources.dir=${test.resources.dir}" />
Cedric Beustf2684812011-02-07 15:04:00 -080086 <jvmarg value="-Dsun.io.serialization.extendedDebugInfo=true" />
Cedric Beustdc0051b2010-07-10 07:59:56 -070087 </testng>
88 </target>
89
Cedric Beust88154ea2010-07-16 14:34:16 -070090 <target name="copy-resources" description="Copies resources.">
91 <copy verbose="false"
Cedric Beust6736fec2010-09-06 09:10:28 -070092 file="${src.resources.dir}/testngtasks"
Cedric Beust88154ea2010-07-16 14:34:16 -070093 todir="${build.dir}" />
94 <copy todir="${build.dir}">
nullinc4f6e792010-07-17 17:41:06 -070095 <fileset dir="${src.resources.dir}">
Cedric Beust88154ea2010-07-16 14:34:16 -070096 <exclude name="**/.*" />
97 <exclude name="**/CVS/*" />
98 </fileset>
99 </copy>
100 </target>
101
Cedric Beustdc0051b2010-07-10 07:59:56 -0700102 <target name="run:single" description="Run 1 property file named with the ant property test" depends="compile">
103 <echo message=" -- testng-tests-run1 --"/>
104
105 <testng outputdir="${testng.report.dir}"
106 classpathref="run.cp"
Cedric Beust8f515612011-08-18 11:14:04 -0700107 useDefaultListeners="true"
Cedric Beustdc0051b2010-07-10 07:59:56 -0700108 outputDir="${testng.report.dir}">
Cedric Beust1c00c702010-07-10 08:45:25 -0700109 <xmlfileset dir="${test.resources.dir}" includes="testng-single.xml"/>
Cedric Beust0d58f772010-07-21 14:36:19 -0700110 </testng>
Cedric Beustdc0051b2010-07-10 07:59:56 -0700111
Cedric Beust8f515612011-08-18 11:14:04 -0700112 <echo>Report created in open ${testng.report.dir}/index.html</echo>
Cedric Beustdc0051b2010-07-10 07:59:56 -0700113 </target>
114
115 <target name="run:antprop" description="Run a test to see if ant system propertes are passed correctly" depends="compile">
116 <echo message=" -- testng-tests-run-antprop --"/>
117 <property name="syspropset1" value="value 1"/>
118 <property name="syspropset2" value="value 2"/>
119 <propertyset id="propset1">
120 <propertyref name="syspropset1"/>
121 <propertyref name="syspropset2"/>
122 </propertyset>
123
124 <testng outputdir="${testng.report.dir}"
125 classpathref="run.cp">
Cedric Beust1c00c702010-07-10 08:45:25 -0700126 <xmlfileset dir="${test.resources.dir}" includes="testng-single3.xml"/>
Cedric Beustdc0051b2010-07-10 07:59:56 -0700127 <propertyset refid="propset1"/>
128 <sysproperty key="sysprop1" value="value 3"/>
129 </testng>
130 </target>
131
132 <!-- ==================================================================== -->
133 <!-- Run specific configuration -->
134 <!-- ==================================================================== -->
135 <target name="run:conf"
136 if="testng.conf"
137 depends="clean:reports,compile"
138 description="Run specified tests">
139 <echo message=" -- testng-tests-run --"/>
140 <echo message="using: ${testng.conf}.xml"/>
141
142 <testng classpathref="run.cp"
143 outputDir="${testng.report.dir}">
Cedric Beust1c00c702010-07-10 08:45:25 -0700144 <xmlfileset dir="${test.resources.dir}" includes="${testng.conf}.xml"/>
Cedric Beustdc0051b2010-07-10 07:59:56 -0700145 </testng>
146
147 <antcall target="clean.tmp"/>
148 </target>
149
150
151 <!-- ==================================================================== -->
152 <!-- Reports -->
153 <!-- ==================================================================== -->
154
155 <target name="reports">
156 <junitreport todir="${junit.report.dir}">
157 <fileset dir="${testng.report.dir}">
158 <include name="*.xml"/>
159 <exclude name="testng-failed.xml"/>
160 <exclude name="testng-results.xml" />
161 </fileset>
162 <report format="noframes" todir="${junit.report.dir}"/>
163 </junitreport>
164 </target>
165
166
167 <target name="clean.tmp">
Cedric Beust1af58182010-07-10 11:08:51 -0700168 <delete dir="${test.output.dir}"/>
Cedric Beustdc0051b2010-07-10 07:59:56 -0700169 </target>
170
171 <target name="clean:reports">
172 <delete dir="${report.dir}"/>
173 <delete dir="${junit.report.dir}"/>
174 </target>
175
176 <target name="clean" depends="clean.tmp,clean:reports">
177 <echo message=" -- test clean --"/>
178
179 <delete dir="${test.build.dir}"/>
180 </target>
Cedric Beustc31cd072011-08-03 14:13:37 -0700181
182 <target name="done">
183 <echo>Reports can be found in: open ${testng.report.dir}/index.html</echo>
184 </target>
185
Cedric Beustdc0051b2010-07-10 07:59:56 -0700186</project>