Appstate Declaration

Action

Declares an application state.

Syntax

appstate appstate1() [basedon appstate2] statements
Variable Description
appstate1 An identifier that specifies the name of the application state being declared.
appstate2 Optional: An identifier that specifies an application state upon which to base the definition of appstate1 or none. Statements in appstate2 are executed before those in appstate1 when the application state function is called. If omitted, none is assumed.
statements The 4Test statements that define the application state.

Notes

An application state is typically used to put an application into the state it should be in at the start of a test case.

You can define the application state from scratch or base the definition on another application state, which in turn can be based on another application state, and so on. The base state is the lowest level of application state in this chain of inheritance. The application state DefaultBaseState is predefined for your use by Silk Test Classic.

To associate an application state with a test case, use the appstate keyword when you define the test case. The second example below associates the application state MyAppState, which is based on MyBaseState, with the test case MyTestCase.

  • By default, Silk Test Classic calls the SetAppState function when you enter a test case, in the DefaultTestCaseEnter function.
  • The SetAppState function executes the statements defined in the application state and in each of the application states upon which it is based, starting with the statements in the base state and working up to the application state chain.
  • By default, Silk Test Classic calls the SetBaseState function when you exit a test case, in the DefaultTestCaseExit function.
  • The SetBaseState function executes the statements defined in the lowest level application state only (the base state). For example, suppose a test case uses the application state AppState3, based on AppState2, based on AppState1. Calling the SetBaseState function executes only the statements in AppState1.

Example

appstate MyAppState () basedon MyBaseState
//...
testcase MyTestCase () appstate MyAppState
//...