source: release-kits/wirk3/ant-scripts/tasks/antelope/docs/manual/bk03ch25.html@ 15023

Last change on this file since 15023 was 15023, checked in by oranfry, 16 years ago

did the bulk of the work on wirk3

File size: 7.9 KB
Line 
1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 25. Suite Task</title><meta name="generator" content="DocBook XSL Stylesheets V1.68.1"><link rel="start" href="index.html" title="Antelope Users Guide"><link rel="up" href="bk03.html" title="Additional Ant Tasks"><link rel="prev" href="bk03ch24.html" title="Chapter 24. Repeat Task"><link rel="next" href="bk03ch26.html" title="Chapter 26. TestCase Task"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 25. Suite Task</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="bk03ch24.html">Prev</a> </td><th width="60%" align="center">Additional Ant Tasks</th><td width="20%" align="right"> <a accesskey="n" href="bk03ch26.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="suitetask"></a>Chapter 25. Suite Task</h2></div></div></div>
2<STYLE TYPE="text/css"> <!-- @import url(./style.css); --> </STYLE>
3 <p>
4 Modeled after the TestSuite provided by jUnit, this class is an Ant task that
5 looks through the build file that contains this task, calls a 'setUp' target
6 (if it exists), then executes all nested tasks, and last calls
7 a target named 'tearDown' (if it exists). Both 'setUp' and 'tearDown' are
8 optional targets in the build file. A build file may contain multiple suite tasks, note that each invocation will call 'setUp' and 'tearDown', so you may want to use some conditionals to only have them execute once.
9</p><p>
10<span class="bold"><strong>While this task and the associated 'testcase' task work very well, a similar test framework has been created by the Ant development team. You may want to check out that framework as it is likely to be the "standard" Ant test framework. Look for "AntUnit" at http://ant.apache.org.</strong></span>
11</p><p>
12 Typically, the nested tasks are TestCases, although they can be any task as appropriate to your testing. The nested tasks may also be Suites, so you can group your tests easily. Nested tasks are executed in order.
13</p><p>
14 Suite may also hold FileSets. Each file in the FileSet will be treated as a file suitable for use by a TestCase and will be executed as such. This makes it easy to run an entire directory of tests without having to specify a TestCase for each one individually.
15</p><p>
16To use this task in your build files, include a task definition like this:
17</p><pre class="programlisting">
18
19 &lt;taskdef name="suite" classname="ise.antelope.tasks.Suite"/&gt;
20
21</pre><p>
22</p><p>
23</p><div class="table"><a name="id2525911"></a><p class="title"><b>Table 25.1. Suite Attributes</b></p><table summary="Suite Attributes" border="1"><colgroup><col><col><col><col></colgroup><thead><tr><th>Attribute</th><th>Description</th><th>Default</th><th>Required</th></tr></thead><tbody><tr><td>enabled</td><td>Determines if this suite should be ran. By using a property for this attribute, it is easy to turn off/on multiple tests.</td><td>On</td><td>No</td></tr><tr><td>assertenabled</td><td>Generally tests will use the Assert task. This attribute sets whether asserts should be enabled.</td><td>Yes</td><td>No</td></tr><tr><td>showoutput</td><td>If true, show intermediate test results</td><td>Yes</td><td>No</td></tr><tr><td>showsummary</td><td>If true, show a summary of test results at the end of the test run.</td><td>Yes</td><td>Yes</td></tr></tbody></table></div><p>
24</p><p>
25In the example below, the "suite" tasks is a top-level task, so will execute automatically. This example does not use 'setUp' or 'tearDown' targets.
26</p><p>
27</p><pre class="programlisting">
28
29&lt;project name="mathtest" basedir="." xmlns:a="antlib:ise.antelope.tasks"&gt;
30 &lt;description&gt;
31 Build file to run unit tests for the Math task
32 &lt;/description&gt;
33
34 &lt;a:suite&gt;
35 &lt;a:testcase file="math_basic_tests.xml"/&gt;
36 &lt;a:testcase file="math_rules_tests.xml"/&gt;
37 &lt;a:testcase file="math_precision_tests.xml"/&gt;
38 &lt;/a:suite&gt;
39
40 &lt;!-- alternatively, a fileset could be used:
41 &lt;a:suite&gt;
42 &lt;fileset dir="${basedir}"&gt;
43 &lt;include name="math_*.xml"/&gt;
44 &lt;/fileset&gt;
45 &lt;/a:suite&gt;
46 --&gt;
47&lt;/project&gt;
48
49$ ant -f mathtest2.xml
50Buildfile: mathtest2.xml
51 [testcase] +-------------------------------------------+
52 [testcase] + mathtest
53 [testcase] +-------------------------------------------+
54
55test6:
56 [testcase] ERROR: test6 failed: string or property must be set.
57
58test5:
59 [testcase] test5 passed.
60
61test4:
62 [testcase] test4 passed.
63
64test3:
65 [testcase] test3 passed.
66
67test2:
68 [testcase] test2 passed.
69
70test1:
71 [testcase] test1 passed.
72 [testcase] +-------------------------------------------+
73 [testcase] + mathtest
74 [testcase] +-------------------------------------------+
75 [testcase]
76 [testcase] ---- Errors ---------------------------------
77 [testcase] ERROR: test6 failed: string or property must be set.
78 [testcase] ---- Results --------------------------------
79 [testcase] Ran 6 out of 6 tests.
80 [testcase] Passed: 5
81 [testcase] Warning: 0
82 [testcase] Failed: 1
83 [testcase] +-------------------------------------------+
84 [testcase] +-------------------------------------------+
85 [testcase] + math_precision_tests
86 [testcase] +-------------------------------------------+
87
88test11:
89 [echo] Division by zero test
90 [a:try] Task 'a:math' in target 'test11' failed, error message is: java.lang.ArithmeticException
91 [testcase] ERROR: test11 failed: java.lang.ArithmeticException: / by zero
92
93test10:
94 [echo] Circle area test
95 [testcase] ERROR: test10 failed: string or property must be set.
96 [testcase] +-------------------------------------------+
97 [testcase] + math_precision_tests
98 [testcase] +-------------------------------------------+
99 [testcase]
100 [testcase] ---- Errors ---------------------------------
101 [testcase] ERROR: test11 failed: java.lang.ArithmeticException: / by zero
102 [testcase] ERROR: test10 failed: string or property must be set.
103 [testcase] ---- Results --------------------------------
104 [testcase] Ran 2 out of 2 tests.
105 [testcase] Passed: 0
106 [testcase] Warning: 0
107 [testcase] Failed: 2
108 [testcase] +-------------------------------------------+
109 [testcase] +-------------------------------------------+
110 [testcase] + math_rules_tests
111 [testcase] +-------------------------------------------+
112
113test7.2:
114 [testcase] test7.2 passed.
115
116test7.1:
117 [testcase] test7.1 passed.
118
119test7.0:
120 [testcase] test7.0 passed.
121
122test8.3:
123 [testcase] test8.3 passed.
124
125test8.2:
126 [testcase] test8.2 passed.
127
128test9:
129 [testcase] test9 passed.
130
131test8.1:
132 [testcase] test8.1 passed.
133
134test8.0:
135 [testcase] test8.0 passed.
136 [testcase] +-------------------------------------------+
137 [testcase] + math_rules_tests
138 [testcase] +-------------------------------------------+
139 [testcase] ---- Results --------------------------------
140 [testcase] Ran 8 out of 8 tests.
141 [testcase] Passed: 8
142 [testcase] Warning: 0
143 [testcase] Failed: 0
144 [testcase] +-------------------------------------------+
145 [suite] ++-- Totals -------------------------------++
146 [suite] ++ Total Ran 16 out of 16 tests.
147 [suite] ++ Total Passed: 13
148 [suite] ++ Total Warnings: 0
149 [suite] ++ Total Failed: 3
150 [suite] ++-----------------------------------------++
151
152BUILD SUCCESSFUL
153Total time: 1 second
154
155</pre><p>
156</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="bk03ch24.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="bk03.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="bk03ch26.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 24. Repeat Task </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 26. TestCase Task</td></tr></table></div></body></html>
Note: See TracBrowser for help on using the repository browser.