Often more complex application do not consist of just a single executable. Instead the main application launches sub-processes which also open a user interface.
Squish is designed in a way to also hook into sub-processes started by the main application under test (AUT). But depending on the platform and the toolkit on which the AUT is based, hooking into sub-processes either works out of the box or needs some small adjustments. This article gives an overview of adjustments that need to be done, if any, or when sub-process hooking works automatically.
Hooking into Sub-Processes in Squish for Qt:
In squish for Qt on Windows there are two ways to enable Squish to hook into the sub-processes started by the AUT:
1. One solution is to make some small changes to the AUT’s source code. This means running a wrapper program (dllpreload.exe, shipped with Squish), that actually starts the sub-process program.
For example, suppose that the AUT had the following source code to start a sub-process:
QProcess process; process.start("subprogram.exe");
To change this to work with Squish, change the AUT in two ways. First add a new command line argument, say –testing, that when given sets a global Boolean, say, TESTING to true. Now update the code that calls the Sub-Process as follows:
QProcess process; QStringList commands; if (TESTING) commands.append("dllpreload.exe"); commands.append("subprogram.exe"); process.start(commands, commands.mid(1));
When TESTING isn’t defined the commands string list will only contain one item („subprogram.exe“), and commands.mid(1) will harmlessly return an empty list.
To make the change effective, in the Settings view, add –testing to the AUT’s Arguments.
Now, when Squish executes the AUT on Windows and the sub-process is started, what will actually happen is that Squish’s dllpreload.exe program will be started with the intended application (e.g., subprogram.exe) as its first argument, and any other arguments passed as arguments to the intended application as normal. This means that the AUT and sub-process‘ behavior will be unchanged.
2. The other solution is to launch the sub-process using dllpreload.exe without needing to modify the AUT’s source code. In order for Squish to be able to hook into the application the applications needs to be started via dllpreload.exe. Here are the steps to be performed:
- Rename the ’subprocess‘ executable to have an underscore before the period (e.g., rename subprocess.exe to subprocess_.exe)
- Copy dllpreload.exe into the same directory as subprocess_.exe
- Rename the copied dllpreload.exe to subprocess.exe
Now, when the AUT is executed, it is really dllpreload.exe that gets executed, and dllpreload.exe is smart enough to check the name it was called as and will try to execute the executable with the same name but with an underscore before the period.
On macOS and Linux:
To enable Squish for Qt to hook into the sub-processes on macOS and Linux:
- First register the sub-process application with squishserver
- Open the test suite settings by clicking the project’s Test Suite Settings to make the „Settings view“ appear, then check the „Hook into Sub-Processes launched by the application“ checkbox.
In Squish for Qt on Mac and Linux, Squish hooks into all the Sub-Processes started by the AUT. In order to stop squish from attempting to hook into a Sub-Processes launched by an AUT , one can list those processes in <SQUISH_DIR>/etc/ignoredauts.txt file.
Hooking into Sub-Processes in Squish for Java:
Sub-process hooking in Squish or Java works out of the box on both Windows, Linux, Unices and macOS. You just have to make sure that the „Hook into Sub-Processes launched by the application“ checkbox (inside the test suite settings) is checked.
Hooking into Sub-Processes in Squish for Windows:
Sub-process hooking for Squish for Windows also works out of the box. There are no additional settings to be done.
Squish for Windows hooks into all the sub-processes started by the main AUT and sometimes one does not want Squish to hook into certain sub-processes. In such cases one can blacklist the processes Squish should not attempt to hook up to. For this, specify them under “Blacklisted Processes” in the wrapper configuration file (<SQUISH_DIR>/etc/winwrapper.ini).