It is possible for the operator of a Common Test system to receive event notifications continously during a test run. It is reported e.g. when a test case starts and stops, what the current count of successful, failed and skipped cases is, etc. This information can be used for different purposes such as logging progress and results on other format than HTML, saving statistics to a database for report generation and test system supervision.
Common Test has a framework for event handling which is based on the OTP event manager concept and gen_event behaviour. When the Common Test server starts, it spawns an event manager. During test execution the manager gets a notification from the server every time something of potential interest happens. Any event handler plugged into the event manager can match on events of interest, take action, or maybe simply pass the information on. Event handlers are Erlang modules implemented by the Common Test user according to the gen_event behaviour (see the OTP User's Guide and Reference Manual for more information).
As already described, a Common Test server always starts an event manager. The server also plugs in a default event handler which has as its only purpose to relay notifications to a globally registered CT Master event manager (if a CT Master server is running in the system). The CT Master also spawns an event manager at startup. Event handlers plugged into this manager will receive the events from all the test nodes as well as information from the CT Master server itself.
User specific event handlers may be plugged into a Common Test event
manager, either by telling Common Test to install them before the test
run (see below), or by adding the handlers dynamically during the test
run by means of
Event handlers may be installed by means of an
Use the
All event handler modules must have gen_event behaviour. Note also that these modules must be precompiled, and that their locations must be added explicitly to the Erlang code server search path (like in the example).
An event_handler tuple in the argument
{event_handler,EventHandlers} EventHandlers = EH | [EH] EH = atom() | {atom(),InitArgs} | {[atom()],InitArgs} InitArgs = [term()]
Example:
1> ct:run_test([{suite,"test/my_SUITE"},{event_handler,[my_evh1,{my_evh2,[node()]}]}]).
This will install two event handlers for the
Event handlers can also be plugged in by means of
To plug a handler into the CT Master event manager, specify
For an event handler to be able to match on events, the module must
include the header file
General events:
Indicates that the logging process of Common Test has started successfully and is ready to receive IO messages.
Indicates that the logging process of Common Test has been shut down at the end of the test run.
This event indicates that Common Test has finished initial preparations and will begin executing test cases.
This indicates that the last test case has been executed and Common Test is shutting down.
Initial test run information that can be interpreted as: "This test
run will execute
This event informs about the start of a test case, or a group configuration
function. The event is sent also for
This event is sent at the start of each test case (and configuration function
except
This event informs about the end of a test case or a configuration function (see the
This event gets sent for every test case or configuration function that Common Test
has skipped automatically because of either a failed
This event specifies that a test case has been skipped by the user.
It is only ever received if the skip was declared in a test specification.
Otherwise, user skip information is received as a
This is a statistics event with the current count of successful, skipped
and failed test cases so far. This event gets sent after the end of each test case,
immediately following the
Internal events:
An internal event saying that Common Test will start compiling
modules in directory
An internal event saying that Common Test is finished compiling
modules in directory
An internal event used by the Common Test Master process to synchronize particular file operations.
An internal event used by the Common Test Master process to synchronize particular file operations.
The events are also documented in
To ensure that printouts to standard out (or printouts made with