File: build.xml

package info (click to toggle)
testng 6.8.8-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 9,364 kB
  • ctags: 10,275
  • sloc: java: 52,394; xml: 2,984; php: 35; sh: 21; makefile: 5
file content (146 lines) | stat: -rw-r--r-- 5,209 bytes parent folder | download
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
141
142
143
144
145
146
<project name="testng" default="all" basedir="..">

   <property file="build.properties"/>

   <property name="debug" value="true"/>
   <property name="optimize" value="false"/>
   <property name="build.compiler" value="javac1.5" />

   <!-- dirs for test output -->
   <property name="test.output" value="${example.dir}/build/test-output"/>
   <property name="test.report" value="${example.dir}/build/test-report"/>

   <target name="all" depends="prepare,compile,run"/>


   <!-- ==================================================================== -->
   <!-- Compile                                                              -->
   <!-- ==================================================================== -->
   <path id="compile.cp">
      <pathelement location="${testng.jar}"/>
   </path>

   <target name="compile"
           description="compile the examples"
           depends="prepare">
      <echo message="                                 -- testng-compile-examples --"/>

     <javac   debug="true"
              fork="true"
              source="1.5"
              classpathref="compile.cp"
              srcdir="${example.dir}/src"
              destdir="${example.dir}/build/classes"
      />
   </target>

   <target name="prepare">
      <mkdir dir="${example.dir}/build/classes"/>
      <mkdir dir="${test.output}"/>
      <mkdir dir="${test.report}"/>
   </target>

   <!-- ==================================================================== -->
   <!-- Run                                                             -->
   <!-- ==================================================================== -->

   <path id="run.cp">
      <pathelement location="${testng.jar}" />
      <path refid="compile.cp"/>
      <pathelement location="${example.dir}/build/classes"/>
   </path>

   <target  name="run"
            description="run examples with java"
            depends="compile">

      <echo message="                                  testng-run "/>
      <java fork="yes"
            classpathref="run.cp"
            classname="org.testng.TestNG">
         <arg value="-d"/>
         <arg value="${test.output}"/>
         <arg value="${example.dir}/testng.xml"/>
         <jvmarg value="-ea"/>
      </java>
      <echo>Some of these tests should have failed.  Statistics are available at</echo>
      <echo>${test.output}\index.html for a TestNG HTML report</echo>
   </target>

   <target  name="run-task"
            description="run examples using testng task"
            depends="compile">
      <echo message="                                 -- testng-run using the testng task--"/>
     
      <taskdef classpathref="compile.cp" name="testng" classname="com.beust.testng.TestNGAntTask"/>
     
      <testng
               fork="yes"
               classpathref="run.cp"
               outputdir="${test.output}">
         <fileset dir="${example.dir}" includes="testng.xml"/>
      </testng>

      <echo>Some of these tests should have failed, see the file test.out for the details</echo>
      <junitreport todir="${test.report}">
         <fileset dir="${test.output}">
            <include name="*.xml"/>
         </fileset>
         <report format="noframes" todir="${test.report}"/>
      </junitreport>
   </target>

   <target  name="run-task-noxml"
            depends="compile"
            description="run examples using testng task with just -testclass and no xml">
      <testng
               fork="yes"
               classpathref="run.cp"
               outputdir="${test.output}"
               testclass="example1.Test1">
      </testng>
      <echo>Some of these tests should have failed, see the file test.out for the details</echo>
      <antcall target="report"/>
   </target>

   <target  name="run-task-jar"
            depends="compile,testjar"
            description="run examples using testng task with just -testjar and no xml">
      <!-- note that this invocation does not have build/ in the path -->
      <testng
               fork="yes"
               classpathref="compile.cp"
               outputdir="${test.output}"
               testjar="${example.dir}/example.jar">
      </testng>
      <antcall target="report"/>
      <echo>Some of these tests should have failed, see the file test.out for the details</echo>
   </target>

   <target name="testjar"
      description="make a test jar with the property file and the classes we need in it">
      <jar destfile="${example.dir}/example.jar">
         <fileset dir="${example.dir}/build/classes" includes="**/*.class"/>
         <fileset file="${example.dir}/testng.xml"/>
      </jar>
   </target>

   <target name="report"
      description="generate reports using junireport">
      <junitreport todir="${test.report}">
         <fileset dir="${test.output}">
            <include name="*.xml"/>
         </fileset>
         <report format="noframes" todir="${test.report}"/>
      </junitreport>
   </target>

   <target  name="clean"
            description="clean up example results">
      <delete dir="${example.dir}/build/classes"/>
      <delete dir="${test.output}"/>
      <delete dir="${test.report}"/>
      <antcall target="prepare"/>
   </target>

</project>