Table of Contents
Squish for Java hooks up Java sub-processes automatically, if they are launched through java (or java.exe, javaw.exe). However, further setup steps may be required. Please contact Squish technical support in case record/replay on Java sub-processes does not work for you.
When recording sub-processes, the test script will contain calls to the
waitForApplicationLaunch
function. This
function returns an ApplicationContext object for each
application started as a sub-process. (See also, Application Context (Section 6.3.12).) Using context objects makes it possible to
tell Squish which application it should be interacting with at various
points in the test script's execution. (See How to Use ApplicationContext Objects (Section 5.12.3) for details about working with application
contexts.)
Table of Contents
By default, Squish for Qt hooks into the application which is started by the test and ignores any sub-processes that the AUT may start. However, Squish for Qt generally supports testing of programs started as sub-processes, when this is enabled in Squish for Qt.
To enable recording and replaying on Qt sub-processes open the test suite settings by clicking the project's Test Suite Settings to make the Test Suite Settings view (Section 8.2.16) appear, then check the Hook into sub-processes launched by the application checkbox.
Please note that the additional setup steps described in Additional Setup for Hooking up Qt Sub-Processes on Windows (Section 7.7.2.1) or Additional Setup for Hooking up Qt Sub-Processes on Windows Non-Invasively (Section 7.7.2.2) must be applied for recording and replaying on Qt sub-processes on Windows, as well.
When recording sub-processes, the test script will contain calls to the
waitForApplicationLaunch
function. This
function returns an ApplicationContext object for each
application started as a sub-process. (See also, Application Context (Section 6.3.12).) Using context objects makes it possible to
tell Squish which application it should be interacting with at various
points in the test script's execution. (See How to Use ApplicationContext Objects (Section 5.12.3) for details about working with application
contexts.)
(Also see Additional Setup for Hooking up Qt Sub-Processes on Windows Non-Invasively (Section 7.7.2.2) for an alternative approach to this.)
To enable Squish for Qt to hook up sub-processes of the AUT on Windows a small change to the AUT's source code is required, which essentially results in starting the sub-process through a wrapper program (SQUISH_DIR/bin/dllpreload.exe).
The required change to the AUT can be made so that it is only
enabled when the AUT gets started via Squish, for example by
checking for the existence of an environment variable called
SQUISH_PREFIX
. (Squish sets this environment
variable for the AUT process.)
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 subprocess as
follows:
QProcess process; QStringList commands; #ifdef Q_OS_WIN32 if (TESTING) commands.append("dllpreload.exe"); #endif commands.append("subprogram.exe"); process.start(commands[0], 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 Test Suite Settings view (Section 8.2.16) (or for Squish 3, the Test
Suite Settings dialog), 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 exactly what it was before.
When recording sub-processes, the test script will contain calls to the
waitForApplicationLaunch
function. This
function returns an ApplicationContext object for each
application started as a sub-process. (See also, Application Context (Section 6.3.12).) Using context objects makes it possible to
tell Squish which application it should be interacting with at various
points in the test script's execution. (See How to Use ApplicationContext Objects (Section 5.12.3) for details about working with application
contexts.)
(Also see Additional Setup for Hooking up Qt Sub-Processes on Windows (Section 7.7.2.1) for an alternative approach to this.)
To enable Squish for Qt to hook up sub-processes of the AUT on Windows without a change to the AUT's source code (as described in the alternative approach at Additional Setup for Hooking up Qt Sub-Processes on Windows (Section 7.7.2.1)) the following steps must be performed:
Rename the AUT's executable to have an underscore before the
period (e.g., rename myapp.exe
to
myapp_.exe
)
Copy dllpreload.exe
into the same directory as
myapp_.exe
Rename the copied dllpreload.exe
to the AUT's
original name (e.g., to myapp.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.
Squish for Windows hooks up sub-processes automatically. No additional settings or setup steps are required.
To enable recording and replaying on native macOS sub-processes open the test suite settings by clicking the project's Test Suite Settings to make the Test Suite Settings view (Section 8.2.16) appear, then check the Hook into sub-processes launched by the application checkbox.