9
<holder>Ericsson AB, All Rights Reserved</holder>
7
<year>2006</year><year>2009</year>
8
<holder>Ericsson AB. All Rights Reserved.</holder>
12
The contents of this file are subject to the Erlang Public License,
13
Version 1.1, (the "License"); you may not use this file except in
14
compliance with the License. You should have received a copy of the
15
Erlang Public License along with this software. If not, it can be
16
retrieved online at http://www.erlang.org/.
18
Software distributed under the License is distributed on an "AS IS"
19
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
20
the License for the specific language governing rights and limitations
23
The Initial Developer of the Original Code is Ericsson AB.
11
The contents of this file are subject to the Erlang Public License,
12
Version 1.1, (the "License"); you may not use this file except in
13
compliance with the License. You should have received a copy of the
14
Erlang Public License along with this software. If not, it can be
15
retrieved online at http://www.erlang.org/.
17
Software distributed under the License is distributed on an "AS IS"
18
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
19
the License for the specific language governing rights and limitations
26
24
<title>Dependencies between Test Cases and Suites</title>
258
256
case can not run. CT offers a way to declare such dependencies,
259
257
called sequences.</p>
261
<p>A sequence of test cases is declared by means of the function
262
<c>sequences/0</c>. This function should return a list of
263
tuples on the format: <c>{SeqTag,TestCases}</c>. <c>SeqTag</c>
264
is an atom that identifies one particular sequence. <c>TestCases</c>
265
is a list of test case names. Sequences must be included in the list
266
that <c>all/0</c> returns. They are declared as: <c>{sequence,SeqTag}</c>.</p>
259
<p>A sequence of test cases is defined as a test case group
260
with a <c>sequence</c> property. Test case groups are defined by
261
means of the <c>groups/0</c> function in the test suite (see the
262
<seealso marker="write_test_chapter#test_case_groups">Test case groups</seealso>
263
chapter for details).</p>
268
265
<p>For example, if we would like to make sure that if <c>allocate</c>
269
266
in <c>server_b_SUITE</c> (above) crashes, <c>deallocate</c> is skipped,
270
we may declare the sequence:</p>
267
we may define a sequence like this:</p>
273
sequences() -> [{alloc_and_dealloc,[alloc,dealloc]}].
270
groups() -> [{alloc_and_dealloc, [sequence], [alloc,dealloc]}].</pre>
276
272
<p>Let's also assume the suite contains the test case <c>get_resource_status</c>,
277
which is independent of the other two cases. The <c>all</c> function could look
273
which is independent of the other two cases, then the <c>all</c> function could
281
all() -> [{sequence,alloc_and_dealloc}, get_resource_status].
277
all() -> [{group,alloc_and_dealloc}, get_resource_status].</pre>
284
279
<p>If <c>alloc</c> succeeds, <c>dealloc</c> is also executed. If <c>alloc</c> fails
285
280
however, <c>dealloc</c> is not executed but marked as SKIPPED in the html log.
289
284
<p>Test cases in a sequence will be executed in order until they have all succeeded or
290
285
until one case fails. If one fails, all following cases in the sequence are skipped.
291
286
The cases in the sequence that have succeeded up to that point are reported as successful
292
in the log. An arbitrary number of sequence tuples may be specified. Example:</p>
287
in the log. An arbitrary number of sequences may be specified. Example:</p>
295
sequences() -> [{scenarioA, [testA1, testA2]},
296
{scenarioB, [testB1, testB2, testB3]}].
290
groups() -> [{scenarioA, [sequence], [testA1, testA2]},
291
{scenarioB, [sequence], [testB1, testB2, testB3]}].
300
{sequence,scenarioA},
302
{sequence,scenarioB},
306
<note><p>It is not possible to execute a test case which is part of a sequence as a
307
regular (stand alone) test case. It is also not possible to use the same test case in
308
multiple sequences. Remember that you can always work around these limitations if
309
necessary by means of help functions common for the test cases in question.</p></note>
300
<p>It is possible to have sub-groups in a sequence group. Such sub-groups can have
301
any property, i.e. they are not required to also be sequences. If you want the status
302
of the sub-group to affect the sequence on the level above, return
303
<c>{return_group_result,Status}</c> from <c>end_per_group/2</c>, as described in the
304
<seealso marker="write_test_chapter#repeated_groups">Repeated groups</seealso>
305
chapter. A failed sub-group (<c>Status == failed</c>) will cause the execution of a
306
sequence to fail in the same way a test case does.</p>