File: common_test.6

package info (click to toggle)
erlang-manpages 1%3A12.b.3-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 4,188 kB
  • ctags: 2
  • sloc: makefile: 68; perl: 30; sh: 15
file content (273 lines) | stat: -rw-r--r-- 7,743 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
.TH common_test 6 "common_test  1.3.2" "Ericsson AB" "ERLANG APPLICATION DEFINITION"
.SH APPLICATION
Common Test \- A framework for automatic testing of a variety of target nodes
.SH DESCRIPTION
.LP
The \fICommon Test \fR framework is an environment for writing and executing automatic and semi-automatic test cases\&. The framework is based on the underlying implementation as is used with great success in the Visual Test Server (AXD301) and by Erlang/OTP\&. The main function in this framework is the test server which runs all the test cases\&.
.LP
In brief the test server supports:
.RS 2
.TP 2
*
Running multiple test suites
.TP 2
*
Logging of the events in a test suite, on both suite and case levels
.TP 2
*
HTML presentation of test suite results
.TP 2
*
HTML presentation of test suite code
.TP 2
*
Support functions for test suite authors
.TP 2
*
Step by step execution
.RE
.LP
The following sections describes the callback functions the test server expects to find in a test suite\&. For more details see Common Test User\&'s Guide\&. 

.SH TEST CASE CALLBACK FUNCTIONS
.LP
The following functions define the callback interface for a test suite\&.
.SH EXPORTS
.LP
.B
Module:all() -> TestCases | {skip,Reason} 
.br
.RS
.TP
Types
TestCases = [atom() | {sequence, SeqName}]
.br
Reason = term()
.br
SeqName = atom()
.br
.RE
.RS
.LP
MANDATORY 
.LP
This function must return the list of all test cases in the test suite module\&. Each test case is represented by an atom, the name of the test case function\&.
.LP
If \fI{skip, Reason}\fR is returned, all test cases in the module will be skipped, and the \fIReason\fR will be printed on the HTML result page\&.
.LP
For details on sequences, see Dependencies between Test Cases and Suites in the User\&'s Guide\&.
.RE
.LP
.B
Module:sequences() -> Sequences 
.br
.RS
.TP
Types
Sequences = [{SeqName, Testcases}]
.br
SeqName = atom()
.br
Testcases = [atom()]
.br
.RE
.RS
.LP
OPTIONAL 
.LP
See Dependencies between Test Cases and Suites in the User\&'s Guide for details\&.
.RE
.LP
.B
Module:suite() -> [Info] 
.br
.RS
.TP
Types
 Info = {timetrap, Time} | {require, Required} | {require, Name, Required} | {userdata, UserData} | {silent_connections, Conns} | {stylesheet, CSSFile}
.br
 Time = MilliSec | {seconds, integer()} | {minutes, integer()} | {hours, integer()}
.br
 MilliSec = integer()
.br
 Required = Key | {Key, SubKeys}
.br
 Key = atom()
.br
 SubKeys = SubKey | [SubKey]
.br
 SubKey = atom()
.br
 Name = atom()
.br
 UserData = term()
.br
 Conns = [atom()]
.br
 CSSFile = string()
.br
.RE
.RS
.LP
OPTIONAL 
.LP
Use this function to set default data for the test suite\&.
.RE
.LP
.B
Module:init_per_suite(Config) -> NewConfig | {skip,Reason} | {skip_and_save,Reason,Config}
.br
.RS
.TP
Types
 Config = NewConfig = [{Key, Value}]
.br
 Key = atom()
.br
 Value = term()
.br
 Reason = term()
.br
.RE
.RS
.LP
OPTIONAL 
.LP
This function is called as the first test case in the suite\&. It typically contains initialization which is common for all test cases in the suite, and which shall only be done once\&. The \fIConfig\fR parameter is the configuration which can be modified here\&. Whatever is returned from this function is given as \fIConfig\fR to all test cases in the suite\&. If \fI{skip, Reason}\fR is returned, all test cases in the suite will be skipped and \fIReason\fR printed in the overview log for the suite\&.
.LP
For information on \fIsave_config\fR and \fIskip_and_save\fR, please see Dependencies between Test Cases and Suites in the User\&'s Guide\&.
.RE
.LP
.B
Module:end_per_suite(Config) -> void() | {save_config,Config}
.br
.RS
.TP
Types
 Config = [{Key, Value}]
.br
 Key = atom()
.br
 Value = term()
.br
.RE
.RS
.LP
OPTIONAL 
.LP
This function is called as the last test case in the suite\&. It is meant to be used for cleaning up after \fIinit_per_suite\fR\&. For information on \fIsave_config\fR, please see Dependencies between Test Cases and Suites in the User\&'s Guide\&.
.RE
.LP
.B
Module:init_per_testcase(TestCase, Config) -> NewConfig | {skip,Reason}
.br
.RS
.TP
Types
 Config = NewConfig = [{Key, Value}]
.br
 Key = atom()
.br
 Value = term()
.br
 Reason = term()
.br
.RE
.RS
.LP
OPTIONAL
.LP
This function is called before each test case\&. The \fITestCase\fR argument is the name of the test case, and \fIConfig\fR is the configuration which can be modified here\&. Whatever is returned from this function is given as \fIConfig\fR to the test case\&. If \fI{skip, Reason}\fR is returned, the test case will be skipped and \fIReason\fR printed in the overview log for the suite\&.
.RE
.LP
.B
Module:end_per_testcase(TestCase, Config) -> void() | {save_config,Config}
.br
.RS
.TP
Types
Config = [{Key, Value}]
.br
 Key = atom()
.br
 Value = term()
.br
.RE
.RS
.LP
OPTIONAL 
.LP
This function is called after each test case, and can be used to clean up whatever the test case has done\&. The return value is ignored\&. For information on \fIsave_config\fR, please see Dependencies between Test Cases and Suites in the User\&'s Guide
.RE
.LP
.B
Module:testcase() -> [Info] 
.br
.RS
.TP
Types
 Info = {timetrap, Time} | {require, Required} | {require, Name, Required} | {userdata, UserData} | {silent_connections, Conns}
.br
 Time = MilliSec | {seconds, integer()} | {minutes, integer()} | {hours, integer()}
.br
 MilliSec = integer()
.br
 Required = Key | {Key, SubKeys}
.br
 Key = atom()
.br
 SubKeys = SubKey | [SubKey]
.br
 SubKey = atom()
.br
 Name = atom()
.br
 UserData = term()
.br
 Conns = [atom()]
.br
.RE
.RS
.LP
OPTIONAL
.LP
This is the test case info function\&. It shall return a list of tagged tuples that specify various properties regarding the test case\&.
.LP
The \fItimetrap\fR tag sets the maximum time the test case is allowed to take\&. If the timetrap time is exceeded, the test case fails with reason \fItimetrap_timeout\fR\&. \fIinit_per_testcase\fR and \fIend_per_testcase\fR are included in the timetrap time\&.
.LP
The \fIrequire\fR tag specifies configuration variables that are required by the test case\&. If the required configuration variables are not found in any of the configuration files, the test case is skipped\&. For more information about the \&'require\&' functionality, see the reference manual for the function \fIct:require/[1, 2]\fR\&.
.LP
If \fItimetrap\fR and/or \fIrequire\fR is not set, the default values specified in the \fIsuite/0\fR return list will be used\&.
.LP
Apart from the above mentioned tags, there is no limitation for which tags that can be specified in the test case info function\&.
.RE
.LP
.B
Module:testcase(Config) -> ok | {skip,Reason} | {comment,Comment} | {save_config,Config} | {skip_and_save,Reason,Config} | exit() 
.br
.RS
.TP
Types
Config = [{Key, Value}]
.br
 Key = atom()
.br
 Value = term()
.br
.RE
.RS
.LP
MANDATORY 
.LP
This is the implementation of a test case\&. Here you must call the functions you want to test, and do whatever you need to check the result\&. If someting fails, make sure the process crashes or call \fIct:fail/[0, 1]\fR (which also will cause the process to crash)\&.
.LP
Elements from the \fIConfig\fR parameter can be read with the \fI?config\fR macro\&. The \fIconfig\fR macro is defined in \fIct\&.hrl\fR
.LP
You can return \fI{skip, Reason}\fR if you decide not to run the test case after all\&. \fIReason\fR will then be printed in \&'Comment\&' field on the HTML result page\&.
.LP
You can return \fI{comment, Comment}\fR if you wish to print some information in the \&'Comment\&' field on the HTML result page\&.
.LP
If the function returns anything else, it is considered a success\&.
.LP
For information on \fIsave_config\fR and \fIskip_and_save\fR, please see Dependencies between Test Cases and Suites in the User\&'s Guide\&.
.RE