background image
<< Generalizing a Testcase | Testcase - Recording an application state >>
Testcase - Using application states
<< Generalizing a Testcase | Testcase - Recording an application state >>
186
User's Guide
8 G
ENERALIZING
A
T
ESTCASE
Using application states
·
Select the forward (down) direction for the search
·
Make the search case sensitive
Application states
Rather than record the same steps over and over again, it is easier to record
the steps as an application state and then associate the application state with
the relevant testcases. An application state is the state you want your
application to be in after the base state is restored but before you run one or
more testcases.
By creating an application state, you are creating reusable code that saves
space and time. Furthermore, if you need to modify the Setup stage, you
change it once, in the application state routine.
Application states can
be chained together
A testcase can have, at most, one application state associated with it.
However, that application state may itself be based on another previously
defined application state. For example, assume that
·
The testcase Find is associated with the application state Setup
·
The application state Setup is based on the application state OpenFile
·
The application state OpenFile is based on the built-in application state,
DefaultBaseState
SilkTest would execute the programs in this order:
1
DefaultBaseState application state
2
OpenFile application state
3
Setup application state
4
Find testcase
A base state is an
application state
As this example illustrates, the built-in routine DefaultBaseState is itself an
application state. The DefaultBaseState application state is responsible for
restoring the application to the base state in the event the application fails or
is corrupted during testcase execution or between testcases. For more
information, see Chapter 15, "Understanding the Recovery System".
Base the final
application state on
DefaultBaseState
If a testcase is based on a single application state, that application state must
itself be based on DefaultBaseState in order for the testcase to use the
recovery system. Similarly, if a testcase is based on a chain of application
states, the final link in the chain must be DefaultBaseState. In this way,
SilkTest's built-in recovery system is still able to restore the application to its
base state when necessary.