95
95
<p>It is possible to disable the automatic compilation feature by using the
96
<c><![CDATA[-no_auto_compile]]></c> flag with <c><![CDATA[run_test]]></c>, or
96
<c><![CDATA[-no_auto_compile]]></c> flag with <c><![CDATA[ct_run]]></c>, or
97
97
the <c><![CDATA[{auto_compile,false}]]></c> option with
98
98
<c><![CDATA[ct:run_test/1]]></c>. With automatic compilation
99
99
disabled, the user is responsible for compiling the test suite modules
100
(and any help modules) before the test run. Common Test will only verify
101
that the specified test suites exist before starting the tests.</p>
100
(and any help modules) before the test run. If the modules can not be loaded
101
from the local file system during startup of Common Test, the user needs to
102
pre-load the modules before starting the test. Common Test will only verify
103
that the specified test suites exist (i.e. that they are, or can be, loaded).
104
This is useful e.g. if the test suites are transferred and loaded as binaries via
105
RPC from a remote node.</p>
108
<marker id="ct_run"></marker>
105
<title>Running tests from the UNIX command line</title>
110
<title>Running tests from the OS command line</title>
107
<p>The script <c>run_test</c> can be used for running tests from
108
the Unix/Linux command line, e.g.
112
<p>The <c>ct_run</c> program can be used for running tests from
113
the OS command line, e.g.
111
<item><c><![CDATA[run_test -config <configfilenames> -dir <dirs>]]></c></item>
112
<item><c><![CDATA[run_test -config <configfilenames> -suite <suiteswithfullpath>]]></c>
114
<item><c><![CDATA[run_test -config <configfilenames> -suite <suitewithfullpath>
116
<item><c><![CDATA[ct_run -config <configfilenames> -dir <dirs>]]></c></item>
117
<item><c><![CDATA[ct_run -config <configfilenames> -suite <suiteswithfullpath>]]></c>
119
<item><c><![CDATA[ct_run -userconfig <callbackmodulename> <configfilenames> -suite <suiteswithfullpath>]]></c>
121
<item><c><![CDATA[ct_run -config <configfilenames> -suite <suitewithfullpath>
115
122
-group <groupnames> -case <casenames>]]></c></item>
118
<p><c>$ run_test -config $CFGS/sys1.cfg $CFGS/sys2.cfg -dir $SYS1_TEST $SYS2_TEST</c></p>
119
<p><c>$ run_test -suite $SYS1_TEST/setup_SUITE $SYS2_TEST/config_SUITE</c></p>
120
<p><c>$ run_test -suite $SYS1_TEST/setup_SUITE -case start stop</c></p>
121
<p><c>$ run_test -suite $SYS1_TEST/setup_SUITE -group installation -case start stop</c></p>
125
<p><c>$ ct_run -config $CFGS/sys1.cfg $CFGS/sys2.cfg -dir $SYS1_TEST $SYS2_TEST</c></p>
126
<p><c>$ ct_run -userconfig ct_config_xml $CFGS/sys1.xml $CFGS/sys2.xml -dir $SYS1_TEST $SYS2_TEST</c></p>
127
<p><c>$ ct_run -suite $SYS1_TEST/setup_SUITE $SYS2_TEST/config_SUITE</c></p>
128
<p><c>$ ct_run -suite $SYS1_TEST/setup_SUITE -case start stop</c></p>
129
<p><c>$ ct_run -suite $SYS1_TEST/setup_SUITE -group installation -case start stop</c></p>
123
<p>Other flags that may be used with <c>run_test</c>:</p>
131
<p>Other flags that may be used with <c>ct_run</c>:</p>
125
133
<item><c><![CDATA[-logdir <dir>]]></c>, specifies where the HTML log files are to be written.</item>
134
<item><c><![CDATA[-label <name_of_test_run>]]></c>, associates the test run with a name that gets printed
135
in the overview HTML log files.</item>
126
136
<item><c>-refresh_logs</c>, refreshes the top level HTML index files.</item>
127
137
<item><c>-vts</c>, start web based GUI (see below).</item>
128
138
<item><c>-shell</c>, start interactive shell mode (see below).</item>
152
170
<note><p>Directories passed to Common Test may have either relative or absolute paths.</p></note>
154
172
<note><p>Arbitrary start flags to the Erlang Runtime System may also be passed as
155
parameters to <c>run_test</c>. It is, for example, useful to be able to
173
parameters to <c>ct_run</c>. It is, for example, useful to be able to
156
174
pass directories that should be added to the Erlang code server search path
157
175
with the <c>-pa</c> or <c>-pz</c> flag. If you have common help- or library
158
176
modules for test suites (separately compiled), stored in other directories
159
177
than the test suite directories, these help/lib directories are preferrably
160
178
added to the code path this way. Example:</p>
161
<p><c>$ run_test -dir ./chat_server -logdir ./chat_server/testlogs -pa $PWD/chat_server/ebin</c></p>
179
<p><c>$ ct_run -dir ./chat_server -logdir ./chat_server/testlogs -pa $PWD/chat_server/ebin</c></p>
162
180
<p>Note how in this example, the absolute path of the <c>chat_server/ebin</c>
163
181
directory is passed to the code server. This is essential since relative
164
182
paths are stored by the code server as relative, and Common Test changes
165
183
the current working directory of the Erlang Runtime System during the test run!</p>
168
<p>For details on how to generate the <c>run_test</c> script, see the
186
<p>For more information about the <c>ct_run</c> program, see the
169
187
<seealso marker="install_chapter#general">Installation</seealso> chapter.
174
192
<title>Running tests from the Web based GUI</title>
176
<p>The web based GUI, VTS, is started with the <c>run_test</c>
177
script. From the GUI you can load config files, and select
194
<p>The web based GUI, VTS, is started with the <c>ct_run</c>
195
program. From the GUI you can load config files, and select
178
196
directories, suites and cases to run. You can also state the
179
197
config files, directories, suites and cases on the command line
180
198
when starting the web based GUI.
184
<item><c>run_test -vts</c></item>
185
<item><c><![CDATA[run_test -vts -config <configfilename>]]></c></item>
186
<item><c><![CDATA[run_test -vts -config <configfilename> -suite <suitewithfullpath>
202
<item><c>ct_run -vts</c></item>
203
<item><c><![CDATA[ct_run -vts -config <configfilename>]]></c></item>
204
<item><c><![CDATA[ct_run -vts -config <configfilename> -suite <suitewithfullpath>
187
205
-case <casename>]]></c></item>
190
208
<p>From the GUI you can run tests and view the result and the logs.
193
<p>Note that <c>run_test -vts</c> will try to open the Common Test start
211
<p>Note that <c>ct_run -vts</c> will try to open the Common Test start
194
212
page in an existing web browser window or start the browser if it is
195
213
not running. Which browser should be started may be specified with
196
214
the browser start command option:</p>
197
<p><c><![CDATA[run_test -vts -browser <browser_start_cmd>]]></c></p>
215
<p><c><![CDATA[ct_run -vts -browser <browser_start_cmd>]]></c></p>
199
<p><c><![CDATA[$ run_test -vts -browser 'firefox&']]></c></p>
217
<p><c><![CDATA[$ ct_run -vts -browser 'firefox&']]></c></p>
200
218
<p>Note that the browser must run as a separate OS process or VTS will hang!</p>
201
<p>If no specific browser start command is specified, netscape will
219
<p>If no specific browser start command is specified, Firefox will
202
220
be the default browser on Unix platforms and Internet Explorer on Windows.
203
If Common Test fails to start a browser automatically, start your
204
favourite browser manually instead and type in the URL that Common Test
221
If Common Test fails to start a browser automatically, or <c>'none'</c> is
222
specified as the value for -browser (i.e. <c>-browser none</c>), start your
223
favourite browser manually and type in the URL that Common Test
205
224
displays in the shell.</p>
315
336
with <c>dir</c>.</p>
339
<marker id="test_specifications"></marker>
319
<marker id="test_specifications"></marker>
320
341
<title>Using test specifications</title>
322
<p>The most expressive way to specify what to test is to use a so
323
called test specification. A test specification is a sequence of
324
Erlang terms. The terms may be declared in a text file or passed
325
to the test server at runtime as a list (see <c>run_testspec/1</c>
326
in the manual page for <c>ct</c>). There are two general types
327
of terms: configuration terms and test specification terms.</p>
328
<p>With configuration terms it is possible to import configuration
329
data (similar to <c>run_test -config</c>), specify HTML log
330
directories (similar to <c>run_test -logdir</c>), give aliases
331
to test nodes and test directories (to make a specification
332
easier to read and maintain), enable code coverage analysis
333
(see the <seealso marker="cover_chapter#cover">Code Coverage
334
Analysis</seealso> chapter) and specify event_handler plugins
343
<p>The most flexible way to specify what to test, is to use a so
344
called test specification. A test specification is a sequence of
345
Erlang terms. The terms may be declared in a text file or passed
346
to the test server at runtime as a list
347
(see <c>run_testspec/1</c> in the manual page
348
for <c>ct</c>). There are two general types of terms:
349
configuration terms and test specification terms.</p>
350
<p>With configuration terms it is possible to e.g. label the test
351
run (similar to <c>ct_run -label</c>), evaluate arbitrary expressions
352
before starting a test, import configuration
354
<c>ct_run -config/-userconfig</c>), specify HTML log directories (similar
356
<c>ct_run -logdir</c>), give aliases to test nodes and test
357
directories (to make a specification easier to read and
358
maintain), enable code coverage analysis (see
359
the <seealso marker="cover_chapter#cover">Code Coverage
360
Analysis</seealso> chapter) and specify event_handler plugins
335
361
(see the <seealso marker="event_handler_chapter#event_handling">
336
Event Handling</seealso> chapter). There is also a term
337
for specifying include directories that should be passed on
338
to the compiler when automatic compilation is performed
339
(similar to <c>run_test -include</c>, see above).</p>
340
<p>With test specification terms it is possible to state exactly which
341
tests should run and in which order. A test term specifies either
342
one or more suites or one or more test cases. An arbitrary number of test
343
terms may be declared in sequence. A test term can also specify one or
344
more test suites or test cases to be skipped. Skipped suites and cases
345
are not executed and show up in the HTML test log as SKIPPED.</p>
347
<note><p>It is not yet possible to specify test case groups in
348
test specifications. This will be supported in a soon upcoming
362
Event Handling</seealso> chapter). There is also a term for
363
specifying include directories that should be passed on to the
364
compiler when automatic compilation is performed (similar
365
to <c>ct_run -include</c>, see above).</p>
366
<p>With test specification terms it is possible to state exactly
367
which tests should run and in which order. A test term specifies
368
either one or more suites, one or more test case groups, or one
369
or more test cases in a group or suite.</p>
370
<p>An arbitrary number of test terms may be declared in sequence.
371
Common Test will by default compile the terms into one or more tests
372
to be performed in one resulting test run. Note that a term that
373
specifies a set of test cases will "swallow" one that only
374
specifies a subset of these cases. E.g. the result of merging
375
one term that specifies that all cases in suite S should be
376
executed, with another term specifying only test case X and Y in
377
S, is a test of all cases in S. However, if a term specifying
378
test case X and Y in S is merged with a term specifying case Z
379
in S, the result is a test of X, Y and Z in S. To disable this
380
behaviour, it is possible in test specification to set the
381
<c>merge_tests</c> term to <c>false</c>.</p>
382
<p>A test term can also specify one or more test suites, groups,
383
or test cases to be skipped. Skipped suites, groups and cases
384
are not executed and show up in the HTML test log files as
386
<p>When a test case group is specified, the resulting test
388
<c>init_per_group</c> function, followed by all test cases and
389
sub groups (including their configuration functions), and
390
finally the <c>end_per_group</c> function. Also if particular
391
test cases in a group are specified, <c>init_per_group</c>
392
and <c>end_per_group</c> for the group in question are
393
called. If a group which is defined (in <c>Suite:group/0</c>) to
394
be a sub group of another group, is specified (or particular test
395
cases of a sub group are), Common Test will call the configuration
396
functions for the top level groups as well as for the sub group
397
in question (making it possible to pass configuration data all
398
the way from <c>init_per_suite</c> down to the test cases in the
351
401
<p>Below is the test specification syntax. Test specifications can
352
be used to run tests both in a single test host environment and in
353
a distributed Common Test environment. Node parameters are only relevant in the
354
latter (see the chapter about running Common Test in distributed mode for information).
355
For details on the event_handler term, see the
356
<seealso marker="event_handler_chapter#event_handling">Event Handling</seealso>
402
be used to run tests both in a single test host environment and
403
in a distributed Common Test environment (Large Scale
404
Testing). The node parameters in the init term are only
405
relevant in the latter (see the
406
<seealso marker="ct_master_chapter#test_specifications">Large
407
Scale Testing</seealso> chapter for information). For details on
408
the event_handler term, see the
409
<seealso marker="event_handler_chapter#event_handling">Event
410
Handling</seealso> chapter.</p>
358
411
<p>Config terms:</p>
360
413
{node, NodeAlias, Node}.
416
{init, [NodeAlias], InitOptions}.
419
{label, NodeRefs, Label}.
421
{multiply_timetraps, N}.
422
{multiply_timetraps, NodeRefs, N}.
424
{scale_timetraps, Bool}.
425
{scale_timetraps, NodeRefs, Bool}.
362
427
{cover, CoverSpecFile}.
363
{cover, NodeRef, CoverSpecFile}.
428
{cover, NodeRefs, CoverSpecFile}.
365
430
{include, IncludeDirs}.
366
431
{include, NodeRefs, IncludeDirs}.
368
433
{config, ConfigFiles}.
369
434
{config, NodeRefs, ConfigFiles}.
436
{userconfig, {CallbackModule, ConfigStrings}}.
437
{userconfig, NodeRefs, {CallbackModule, ConfigStrings}}.
371
439
{alias, DirAlias, Dir}.
373
443
{logdir, LogDir}.
374
444
{logdir, NodeRefs, LogDir}.
377
447
{event_handler, NodeRefs, EventHandlers}.
378
448
{event_handler, EventHandlers, InitArgs}.
379
449
{event_handler, NodeRefs, EventHandlers, InitArgs}.
451
{ct_hooks, CTHModules}.
452
{ct_hooks, NodeRefs, CTHModules}.
381
454
<p>Test terms:</p>
383
456
{suites, DirRef, Suites}.
384
457
{suites, NodeRefs, DirRef, Suites}.
459
{groups, DirRef, Suite, Groups}.
460
{groups, NodeRefsDirRef, Suite, Groups}.
462
{groups, DirRef, Suite, Group, {cases,Cases}}.
463
{groups, NodeRefsDirRef, Suite, Group, {cases,Cases}}.
386
465
{cases, DirRef, Suite, Cases}.
387
466
{cases, NodeRefs, DirRef, Suite, Cases}.
449
537
<item>Secondly, the test for system t2 should run. The included suites are
450
538
t2B and t2C. Included are also test cases test4, test1 and test7 in suite
451
539
t2A. Note that the test cases will be executed in the specified order.</item>
452
<item>Lastly, all suites for systems t3 are to be completely skipped and this
540
<item>Lastly, all suites for systems t3 are to be completely skipped and this
453
541
should be explicitly noted in the log files.</item>
543
<p>It is possible to specify initialization options for nodes defined in the
544
test specification. Currently, there are options to start the node and/or to
545
evaluate any function on the node.
546
See the <seealso marker="ct_master_chapter#ct_slave">Automatic startup of
547
the test target nodes</seealso> chapter for details.</p>
455
548
<p>It is possible for the user to provide a test specification that
456
549
includes (for Common Test) unrecognizable terms. If this is desired,
457
550
the <c>-allow_user_terms</c> flag should be used when starting tests with
458
<c>run_test</c>. This forces Common Test to ignore unrecognizable terms.
551
<c>ct_run</c>. This forces Common Test to ignore unrecognizable terms.
459
552
Note that in this mode, Common Test is not able to check the specification
460
553
for errors as efficiently as if the scanner runs in default mode.
461
554
If <c>ct:run_test/1</c> is used for starting the tests, the relaxed scanner