Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

How do I stop SilkTest DefaultBaseState invoking two instances of the AUT?

How do I stop SilkTest DefaultBaseState invoking two instances of the AUT?

If you are encountering an issue using the DefaultBaseState where SilkTest is invoking two instances of the application under test (AUT) during test run, use Shell commands to invoke the application following the sample below:


dll "shell32"
int ShellExecuteW (int iHandle, String lpOperation, String lpFile, String lpParameters, String lpDirectory, int nShowCmd)

testcase OPEN_APP() appstate none
int iHandle
int iShowCmd
string lpOperation
string lpFile
string lpParameters
string lpDirectory

// Sets iHandle = to the window handle for the desktop
iHandle = Desktop.GetHandle()
// The operation that is to be carried out
lpOperation = "open"
// The file on which this operation will be carried out
lpFile = "filename.exe"
// Any additional parameters to the commandline
lpParameters = " "
// The working directory in which this will be run
lpDirectory = "C:\directory_path_to_application"
// a flag that determines how the command will be shown
iShowCmd = 5

// Open application
ShellExecuteW (iHandle,lpOperation,lpFile,lpParameters,lpDirectory,iShowCmd)

Once you have ensured that the shell script successfully invokes a single instance of your application, create an appstate in your frame file and place the above script in the appstate (remove any previously recorded actions if you recorded an appstate to generate the appstate declaration).

Now you should be able to create a testcase based on this appstate to invoke your application.

If you find that during test execution, that SilkTest continues to invoke a second instance of the application, this is because SilkTest is again calling the DefaultBaseState from the DefaultTestcaseExit function.

DefaultTestCaseExit (BOOLEAN bException)
if (bException)
ExceptLog ()

SetBaseState ()

DefaultTestcaseExit (BOOLEAN bException) – logs an exception to the results file when a testcase exits because of an exception. The function then executes the SetBaseState function, which calls a base state function that you have defined or the DefaultBaseState function.

To work around this, you would have to override DefaultTestcaseExit function in the default.inc file by creating a TestcaseExit () function in your frame file as below:

TestCaseExit (BOOLEAN bException)
if (bException)
ExceptLog ()

Key here is that we have removed the SetBaseState() call, therefore, DefaultTestcaseExit() is not called, but the value of bException is used to determine if an error occurred during the testcase execution.

Old KB# 23564


Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-02-15 19:36
Updated by:
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.