Attaching to running Qt applications

Last edited on

Setting up attaching to running applications

Step 1 - Register an attachable AUT

Before you can attach to a running instance of your application, you first need to register an "Attachable AUT" for where the application will be listening for Squish to connect to it.

In the Squish IDE:

Open Edit > Server Settings > Manage AUTs... > Attachable AUTs to register an "Attachable AUT", for example with the name "MyApplicationAttachable", with the host "127.0.0.1" and port "9999".

In command line: Enter the bin directory in your Squish Installation in a terminal or shell.

squishserver --config addAttachableAUT MyApplicationAttachable 127.0.0.1:9999
In your terminal or shell

(Use a different host name or IP address and port numbers as required, for example the IP address of a remote computer or remote device if you plan to attach to an application running there.)

Step 2 - Start the application

On desktop operating systems or embedded/other devices:

On non-desktop operating systems (Squish hook built into the application):

Step 3 - Create a new test script

def main():
    attachToApplication("MyApplicationAttachable")
    test.breakpoint()
test.py

Step 4 - Use "Record Snippet"

To record on an attachable AUT you can either record a full testscript or record Snippets. For the latter you must first have the IDE be in a brakepoint. After that follow the steps below.

Troubleshooting

When the application is started via startaut with the --verbose you should see the following messages in the output from startaut, the parts in single quotes are placeholders that may differ depending on your setup :

Listening on port 'CHOSEN_PORT' for incoming connections

Finished initializing Squish Qt toolkit support for AUT 'AUT_NAME'

If those messages are not present or you get an error message like this in the test results connection to AUT refused it can be useful to check if there is any process listening on the network port you provided with the --port argument to startaut at all.

This can done through any third party tool that can open a newtork connection and also through the Python Interpreter in Squish

Connection to AUT refused .

Attaching to Running Applications