Squish doesn't only provide the tools to record and edit tests. In addition debugging and inspection tools are available which assist test engineers when post-editing and debugging test scripts.
The script debugger in the Squish IDE allows to set break points in the script. This can be useful to insert verification points (see Inserting a Verification Point (Section 5.2.1)) or to record from a breakpoint as discussed later in this chapter. But it also can be used to step through the test script using | and |.
To halt a test run without setting a break point, | can be used. To continue a test run, use | again.
Sometimes during test execution it is interesting to follow the currently executed line in the Squish IDE. For this purpose it is possible to specify in the Editor's tab of the preferences dialog | to highlight the current line during test execution by checking the corresponding check box.
In some cases it is required to extend an existing test case with more actions. It would be tedious to record everything from scratch just to e.g. click an additional button in the test. Sometimes it is easily possible to just manually write a few lines, but often it would be easier to record the new actions.
This approach is also very useful if e.g. each test needs to run the same initialization actions on the AUT (opening a file or so) which is provided by a shared script. A new test case could then be created by writing a script which loads the shared script (see Storing and Locating Data- and Scriptfiles (Section 16.11.1) and executes this initialization actions. After that a new test should be recorded.
This is possible in Squish by setting a breakpoint in a test script located where the newly recording actions should be inserted. Then you execute the test until this breakpoint is hit. After that you can choose | which starts recording on the running AUT. By choosing | recording will be stopped and the newly recorded actions will be inserted into the test script at the breakpoint.
In the chapter Verification Points (Section 16.10) and the chapter Inserting a Verification Point (Section 5.2.1) in the tutorial Tutorial: Creating the First Test with Squish for Qt (Chapter 5) the Spy was used to insert verification points.
The Spy can be used stand-alone (without a test script) in all
editions except Squish for Web to inspect the application, its objects and
properties. For Squish for Web, to use the Spy, you need a test script
which opens an URL. Set a breakpoint after the
loadUrl call, and execute the test script until
that point to use Spy.
Using Spy is especially useful when manually writing script code to find out the names of objects and which properties of certain objects are accessible.
To start the Spy, activate | in the menu of the Squish IDE. Now the AUT of the currently active test suite will be started and the Spy window appears in the Squish IDE, or in Squish for Web, choose the menu option after you started the test script and hit the breakpoint.
There are three different modes in the Spy
Run: The Spy is active and you can navigate in the object and property hierarchy views. In this mode all user events to the AUT are blocked.
Pause: The Spy is inactive and all events to the AUT are processed normally. You usually switch to this mode when you want to e.g spy on a dialog in the AUT. For this reason you will pause the Spy, open the dialog in the AUT and then choose Run in the Spy again which will let you navigate the object hierarchy and properties of the now opened dialog.
Pick Object: The Spy switches the AUT into a picking mode. In this mode you can select a widget in the AUT by moving the mouse over the widgets and clicking on it. If you selected a widget in the AUT, its object hierarchy and properties will get displayed in the Spy's views.
To exit the Spy, choose | again.
Initially the Spy is in the Run state. To e.g. find out the name of a widget in the AUT, switch to the Pick Object state by activating | in the menu of the Squish IDE. Now we can switch the focus to the AUT which has been started. When moving the mouse over the AUT's windows, the objects under the mouse pointer are selected with a red frame and the name and type of the hovered widgets are displayed in a tool tip. So we move the mouse over the desired widget in the AUT and click on it.
The Spy will automatically switch back to
Run mode and display the selected object, its
children and properties in the Spy views. By right clicking on the
object in the Spy view, you can copy the name to the clipboard and
paste it into the test script where needed (e.g. for a
findObject call).