13
13
compliance with the License. You should have received a copy of the
14
14
Erlang Public License along with this software. If not, it can be
15
15
retrieved online at http://www.erlang.org/.
17
17
Software distributed under the License is distributed on an "AS IS"
18
18
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
19
19
the License for the specific language governing rights and limitations
24
24
<title>Writing Test Suites</title>
157
158
<c>{skipped,Reason}</c> (where Reason is a user specific term).
161
<p>The <c>end_per_testcase/2</c> function is called even after a
162
test case terminates due to a call to <c>ct:abort_current_testcase/1</c>,
163
or after a timetrap timeout. However, <c>end_per_testcase</c>
164
will then execute on a different process than the test case
165
function, and in this situation, <c>end_per_testcase</c> will
166
not be able to change the reason for test case termination by
167
returning <c>{fail,Reason}</c>, nor will it be able to save data with
168
<c>{save_config,Data}</c>.</p>
160
170
<p>If <c>init_per_testcase</c> crashes, the test case itself is skipped
161
171
automatically (so called <em>auto skipped</em>). If <c>init_per_testcase</c>
162
172
returns a <c>skip</c> tuple, also then will the test case be skipped (so
682
692
<c>end_per_suite</c> execute, like test cases, on dedicated Erlang
698
<title>Timetrap timeouts</title>
699
<marker id="timetraps"></marker>
686
700
<p>The default time limit for a test case is 30 minutes, unless a
687
<c>timetrap</c> is specified either by the test case info function
688
or the <c>suite/0</c> function.
701
<c>timetrap</c> is specified either by the suite info function
702
or a test case info function. The timetrap timeout value defined
703
in <c>suite/0</c> is the value that will be used for each test case
704
in the suite (as well as for the configuration functions
705
<c>init_per_suite/1</c> and <c>end_per_suite</c>). A timetrap timeout
706
value set with the test case info function will override the value set
707
by <c>suite/0</c>, but only for that particular test case.</p>
708
<p>It is also possible to set/reset a timetrap during test case (or
709
configuration function) execution. This is done by calling
710
<c>ct:timetrap/1</c>. This function will cancel the current timetrap
711
and start a new one.</p>
712
<p>Timetrap values can be extended with a multiplier value specified at
713
startup with the <c>multiply_timetraps</c> option. It is also possible
714
to let Test Server decide to scale up timetrap timeout values
715
automatically, e.g. if tools such as cover or trace are running during
716
the test. This feature is disabled by default and can be enabled with
717
the <c>scale_timetraps</c> start option.</p>
718
<p>If a test case needs to suspend itself for a time that also gets
719
multipled by <c>multiply_timetraps</c>, and possibly scaled up if
720
<c>scale_timetraps</c> is enabled, the function <c>ct:sleep/1</c>