Setting Up the Recovery System for Multiple Local Applications

Problem

By default, the recovery system will only work for the single application assigned to the const wMainWindow. With distributed testing, you can get recovery on multiple applications by using multitestcase instead of testcase.

You might ask whether you can get the recovery system to work on multiple applications that are running locally using multitestcase locally. The answer is no; multitestcase is for distributed testing only.

But you can use the following solution instead, using testcase.

Solution

To get recovery for multiple local applications, set up your frame file to do the following:

  1. Get standard wMainWindow declarations for each application. The easiest way is to select File > New > Test Frame for each application, then combine the wMainWindow declarations into a single frame file or include them with use.
  2. Make the global wMainWindow a variable of type WINDOW, rather than a constant.
  3. Assign one of the windows to wMainWindow as a starting point.
  4. Create a LIST OF WINDOW and assign the wMainWindow identifier for each application you are dealing with to it.
  5. Define a TestcaseEnter function so that you reassign the wMainWindow variable and call SetAppState on each MainWin in turn.
  6. Define a TestcaseExit function so that you reassign the wMainWindow variable and call SetBaseState on each MainWin in turn.
  7. Then use DefaultBaseState, or your own base state if you want, with each of your test cases. In your test case, use SetActive each time you switch from one application to the other.

Example

The example consists of two sample files. The sample files are for the Classic Agent. If you want to use the example with the Open Agent, you have to change the sample code. For the sample script file, see two_apps.t. For the sample include file, see two_apps.inc. The example uses two demo applications shipped with Silk Test Classic, the Text Editor and the Test Application. To see that the recovery system is working for both applications, turn on the two debugging options in Runtime Options and look at the transcript after running the test script.

The first test case has an intentional error in its last statement to demonstrate the recovery system. The test case also demonstrates how to move data from one application to another with Clipboard.GetText and Clipboard.SetText.

Because the recovery system is on, the DefaultBaseState will take care of invoking each application if it is not already running and will return to the DefaultBaseState after each test case, even if the test case fails.

You can print the sample files out or copy them to the Clipboard, then paste them into Silk Test Classic. You might have to do some cleanup where the indentation of lines is incorrect in the pasted file.