| Recovery System |
Subsystem list |
Top level |
Introduction
How QA Partner's Recovery System Works
Defining Recovery Behaviour
How to Use Recovery Objects
Defining Testcases
What Actually Happens During Recovery
In general terms, a recovery system should do the following:
ScriptEnter() is called at the beginning of each test script.
ScriptExit() is called at the end of each test script.
TestCaseEnter() is called at the beginning of each testcase.
TestCaseExit() is called at the end of each testcase.
Note that all of these functions are called automatically, behind your back.
You do not need to -- in fact, you must not -- call them explicitly in your code.
Note also that TestCaseExit is called regardless of whether the testcase
exited normally or because an exception was raised.
Likewise, ScriptExit is called regardless of whether the script exited
normally or because an exception was raised.
RECbase.
Each recovery object is responsible for ensuring that a well-defined
part of the system is in a known state, called the "base state",
which the script expects the system to be in.
The part of the system for which a recovery object is responsible
is called the "recovery target".
Most recovery targets are windows; each window in the application under
test will typically have its own recovery object.
In addition, there will usually be a recovery object for the entire
application under test, usually derived from
RECapplication.The documentation for the recovery object classes is primarily focussed on how to override them to create new recovery classes. Script writers will often create new recovery classes and objects, but will typically not invoke recovery objects very much.
The recovery system keeps track of a single recovery object, known
as the "active recovery object", which is used during the four
recovery phases (ScriptEnter, TestcaseEnter, TestcaseExit,
and ScriptExit).
You can change the active recovery object at any time by calling
RECsetActive.
While there can be only one active recovery object at a time,
it will typically be derived from the
RECgroup class,
which contains other recovery objects.
Therefore, you can effectively have as many active recovery objects
as you need.
There is one special case for defining the active recovery object:
since ScriptEnter is called before main, you must
specify the initial recovery object by defining
grRECinitial.
RECbase.
Near the top of the body of the testcase, there must be a call to
CUtestcaseFeature
that specifies the functional area that the testcase is testing.
This requirement is enforced at run time.
CUbeginFeatureTest
and CUendFeatureTest
may be called outside a testcase to partially specify a feature,
in which case the CUfeature passed to the testcase
is relative to the current feature block.
CUbeginFeatureTest and CUendFeatureTest
may not be called from inside a testcase.
There must be a one-to-one correspondence between testcases and testpoints.
This requirement is enforced at run time.
If the testcase takes parameters, then it must log information that
distinguishes between different invocations of the testcase.
This is accomplished by placing a call to
CUdisambiguateTC
near the top of the body of the testcase.
At some appropriate point inside the testcase, it must set the test phase
to eCU_TEST_EXECUTE by calling
CUlogTestPhase.
This should happen after the testcase performs any setup (if any),
immediately before it begins the "real" part of the test.
If the testcase performs explicit cleanup or verification, it must set the
test phase to eCU_TEST_CLEANUP and/or eCU_TEST_VERIFY.
Testcases may modify the currently active recovery object,
but this practice should be avoided.
grRECinitial.BeHappy(eREC_SCRIPT_ENTER).
If it fails, terminate the script.
CUfeature, push it onto the feature stack,
and set the test phase to Setup.
RECstubNextTestcase.
RECgetActive().IsHappy(eREC_TESTCASE_ENTER, TRUE).
IsHappy returns FALSE, call
RECgetActive().BeHappy(eREC_TESTCASE_ENTER).
If BeHappy fails, terminate the script.
RECgetActive().IsHappy(eREC_TESTCASE_EXIT).
If the testcase was (so far) successful, pass TRUE for logFirstFailure;
otherwise pass FALSE.
IsHappy returns FALSE, call
RECgetActive().BeHappy(eREC_TESTCASE_EXIT).
If BeHappy fails, terminate the script.
RECgetActive().BeHappy(eREC_SCRIPT_EXIT).