SilkTest Workbench: How can an application be launched from a Workbench .Net script, without using the BaseState; and kept running between tests executed from Silk Central?
In some scenarios it may be beneficial or even neceesary; to launch an application under test through a .Net script, rather than using the built-in BaseState functionality. A typical way to accomplish this is to use the Process.Start() method of the System.Diagnostics namespace. e.g.
However when this script is run from SilkCentral it is executed from the commandline program(STW.exe) and a Windows Job object is created. This approach is adopted so that, in the event that the Workbench or STW.exe processes crash, the launched application will also be closed automatically.
One side effect of this approach is that any child processes launched by the Workbench(including any processes started through the script); are closed automatically when the test is completed. This is not an issue when running tests directly from the Workbench; but when the same script runs from SilkCentral, the notepad application will close when the Workbench terminates on completion of the script. This behavior may not be the desired if you need the application to remain running between tests.
The solution is to specify the 'CREATE_BREAKAWAY_FROM JOB' flag when launching the application; but unfortunately the Process class used in the example does not expose the functionality to do this, so the Win32 function must be called directly. The steps to accomplish this are as follows:
1. Create the Win32 class as follows and add a reference to it in your script:
2. Create the RunProcess class that will contain the Start() method, and add a reference to the class in your script:
3. Modify the script to call the Start() method in the RunProcess class to launch the specified application:
You can find the exported script attached to this article - please note that this solution required some changes to STW.exe, so this approach is only valid for SilkTest 17.5 and newer.