Cedric Beust | ac981c4 | 2010-07-10 10:53:57 -0700 | [diff] [blame] | 1 | <project name="testng" default="all" basedir="."> |
Cedric Beust | dc0051b | 2010-07-10 07:59:56 -0700 | [diff] [blame] | 2 | |
| 3 | <property file="build.properties"/> |
| 4 | |
Cedric Beust | 1af5818 | 2010-07-10 11:08:51 -0700 | [diff] [blame] | 5 | <property name="report.dir" value="${test.output.dir}"/> |
Cedric Beust | dc0051b | 2010-07-10 07:59:56 -0700 | [diff] [blame] | 6 | <property name="junit.report.dir" value="${report.dir}/test-tmp"/> |
| 7 | <property name="testng.report.dir" value="${report.dir}"/> |
| 8 | |
Cedric Beust | c31cd07 | 2011-08-03 14:13:37 -0700 | [diff] [blame^] | 9 | <target name="all" depends="prepare,compile,run,reports,done"/> |
Cedric Beust | dc0051b | 2010-07-10 07:59:56 -0700 | [diff] [blame] | 10 | |
| 11 | <!-- ==================================================================== --> |
| 12 | <!-- Compile --> |
| 13 | <!-- ==================================================================== --> |
| 14 | <path id="compile.cp"> |
| 15 | <pathelement location="${testng.jar}" /> |
Cedric Beust | d001f39 | 2010-12-10 13:45:32 -0800 | [diff] [blame] | 16 | <fileset dir="${lib.dir}" includes="${guice2.jar}" /> |
Cedric Beust | dc0051b | 2010-07-10 07:59:56 -0700 | [diff] [blame] | 17 | </path> |
| 18 | |
| 19 | <target name="env:info"> |
| 20 | <echo> |
| 21 | BASEDIR =${basedir} |
Cedric Beust | 1c00c70 | 2010-07-10 08:45:25 -0700 | [diff] [blame] | 22 | TEST.DIR =${test.dir} |
Cedric Beust | dc0051b | 2010-07-10 07:59:56 -0700 | [diff] [blame] | 23 | TEST.BUILD.DIR =${test.build.dir} |
| 24 | REPORT.DIR =${report.dir} |
| 25 | JUNIT.REPORT.DIR =${junit.report.dir} |
| 26 | TESTNG.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 Beust | 1c00c70 | 2010-07-10 08:45:25 -0700 | [diff] [blame] | 37 | srcdir="${test.dir}" |
Cedric Beust | dc0051b | 2010-07-10 07:59:56 -0700 | [diff] [blame] | 38 | 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 Beust | a7d7ad3 | 2011-06-29 10:24:56 -0700 | [diff] [blame] | 54 | <!-- |
Cedric Beust | afd8e4a | 2011-06-01 15:33:26 -0700 | [diff] [blame] | 55 | <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 Beust | a7d7ad3 | 2011-06-29 10:24:56 -0700 | [diff] [blame] | 63 | --> |
Cedric Beust | afd8e4a | 2011-06-01 15:33:26 -0700 | [diff] [blame] | 64 | |
Cedric Beust | a7d7ad3 | 2011-06-29 10:24:56 -0700 | [diff] [blame] | 65 | <!-- ==================================================================== --> |
Cedric Beust | dc0051b | 2010-07-10 07:59:56 -0700 | [diff] [blame] | 66 | <!-- Run --> |
| 67 | <!-- ==================================================================== --> |
| 68 | |
| 69 | <path id="run.cp"> |
Cedric Beust | a7d7ad3 | 2011-06-29 10:24:56 -0700 | [diff] [blame] | 70 | <!-- |
Cedric Beust | afd8e4a | 2011-06-01 15:33:26 -0700 | [diff] [blame] | 71 | <path location="target/instrumented-classes" /> |
| 72 | <path refid="cobertura.classpath" /> |
Cedric Beust | a7d7ad3 | 2011-06-29 10:24:56 -0700 | [diff] [blame] | 73 | --> |
Cedric Beust | dc0051b | 2010-07-10 07:59:56 -0700 | [diff] [blame] | 74 | <path refid="compile.cp"/> |
| 75 | <pathelement location="${test.build.dir}"/> |
| 76 | </path> |
| 77 | |
Cedric Beust | 88154ea | 2010-07-16 14:34:16 -0700 | [diff] [blame] | 78 | <target name="run" description="Run tests" depends="compile,copy-resources"> |
Cedric Beust | dc0051b | 2010-07-10 07:59:56 -0700 | [diff] [blame] | 79 | <echo message=" -- Running tests --"/> |
| 80 | <echo message=" -- ${testng.jar} --" /> |
| 81 | <testng classpathref="run.cp" |
| 82 | outputdir="${testng.report.dir}"> |
Cedric Beust | 1c00c70 | 2010-07-10 08:45:25 -0700 | [diff] [blame] | 83 | <xmlfileset dir="${test.resources.dir}" includes="testng.xml"/> |
Cedric Beust | 93b16a3 | 2010-07-10 08:38:42 -0700 | [diff] [blame] | 84 | <jvmarg value="-Dtest.resources.dir=${test.resources.dir}" /> |
Cedric Beust | f268481 | 2011-02-07 15:04:00 -0800 | [diff] [blame] | 85 | <jvmarg value="-Dsun.io.serialization.extendedDebugInfo=true" /> |
Cedric Beust | dc0051b | 2010-07-10 07:59:56 -0700 | [diff] [blame] | 86 | </testng> |
| 87 | </target> |
| 88 | |
Cedric Beust | 88154ea | 2010-07-16 14:34:16 -0700 | [diff] [blame] | 89 | <target name="copy-resources" description="Copies resources."> |
| 90 | <copy verbose="false" |
Cedric Beust | 6736fec | 2010-09-06 09:10:28 -0700 | [diff] [blame] | 91 | file="${src.resources.dir}/testngtasks" |
Cedric Beust | 88154ea | 2010-07-16 14:34:16 -0700 | [diff] [blame] | 92 | todir="${build.dir}" /> |
| 93 | <copy todir="${build.dir}"> |
nullin | c4f6e79 | 2010-07-17 17:41:06 -0700 | [diff] [blame] | 94 | <fileset dir="${src.resources.dir}"> |
Cedric Beust | 88154ea | 2010-07-16 14:34:16 -0700 | [diff] [blame] | 95 | <exclude name="**/.*" /> |
| 96 | <exclude name="**/CVS/*" /> |
| 97 | </fileset> |
| 98 | </copy> |
| 99 | </target> |
| 100 | |
Cedric Beust | dc0051b | 2010-07-10 07:59:56 -0700 | [diff] [blame] | 101 | <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 Beust | 0d58f77 | 2010-07-21 14:36:19 -0700 | [diff] [blame] | 107 | methods="test.sample.Sample2.method1,test.sample.Sample2.method3" |
Cedric Beust | dc0051b | 2010-07-10 07:59:56 -0700 | [diff] [blame] | 108 | outputDir="${testng.report.dir}"> |
| 109 | <reporter classname="org.testng.reporters.XMLReporter"> |
| 110 | <property name="generateGroupsAttribute" value="true" /> |
| 111 | </reporter> |
Cedric Beust | 0d58f77 | 2010-07-21 14:36:19 -0700 | [diff] [blame] | 112 | <!-- |
Cedric Beust | 1c00c70 | 2010-07-10 08:45:25 -0700 | [diff] [blame] | 113 | <xmlfileset dir="${test.resources.dir}" includes="testng-single.xml"/> |
Cedric Beust | 0d58f77 | 2010-07-21 14:36:19 -0700 | [diff] [blame] | 114 | --> |
| 115 | </testng> |
Cedric Beust | dc0051b | 2010-07-10 07:59:56 -0700 | [diff] [blame] | 116 | |
| 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 Beust | 1c00c70 | 2010-07-10 08:45:25 -0700 | [diff] [blame] | 131 | <xmlfileset dir="${test.resources.dir}" includes="testng-single3.xml"/> |
Cedric Beust | dc0051b | 2010-07-10 07:59:56 -0700 | [diff] [blame] | 132 | <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 Beust | 1c00c70 | 2010-07-10 08:45:25 -0700 | [diff] [blame] | 149 | <xmlfileset dir="${test.resources.dir}" includes="${testng.conf}.xml"/> |
Cedric Beust | dc0051b | 2010-07-10 07:59:56 -0700 | [diff] [blame] | 150 | </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 Beust | 1af5818 | 2010-07-10 11:08:51 -0700 | [diff] [blame] | 173 | <delete dir="${test.output.dir}"/> |
Cedric Beust | dc0051b | 2010-07-10 07:59:56 -0700 | [diff] [blame] | 174 | </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 Beust | c31cd07 | 2011-08-03 14:13:37 -0700 | [diff] [blame^] | 186 | |
| 187 | <target name="done"> |
| 188 | <echo>Reports can be found in: open ${testng.report.dir}/index.html</echo> |
| 189 | </target> |
| 190 | |
Cedric Beust | dc0051b | 2010-07-10 07:59:56 -0700 | [diff] [blame] | 191 | </project> |