Attaching to running Java applications

Last edited on

Setting up attaching to running applications


STEP 1: Register and use your application in Squish

To avoid any hooking problems that are unrelated to attaching, make sure that you can record and replay with your application. To do this, the application has to be registered as a Mapped AUT.

To do this via the Squish IDE:

Go to...

Edit > Server Settings > Manage AUTs... > Mapped AUTs

...and add your application's .exe as a Mapped AUT.

To do this via command line:

"C:\Squish\bin\squishserver" --config addAUT MyApplication "C:\Program Files\MyApplication 1.0"
In cmd.exe

At this point please try to record and replay a short test case to make sure that your application can be successfully started by Squish.


STEP 2: Register an attachable AUT

Before you can attach to a running instance of your application, an Attachable AUT has to be registered.

This is not an actual application, but rather a name of your choosing that will later be used in attachToApplication(), and which stands for the host name/TCP/IP address and port number on which the actual application is listening for connections from Squish.

To do this via 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".

To do this via command line:

"C:\Squish\bin\squishserver" --config addAttachableAUT MyApplicationAttachable 127.0.0.1:9999
In cmd.exe

STEP 3: Start your application

(If your application is already running, but has not been started via Squish/startjavaaut.exe, quit your application.

"C:\Squish\bin\startjavaaut" --verbose --port=9999 "--cwd=C:\Program Files\MyApplication 1.0" MyApplication
In cmd.exe

STEP 4: Create a new test script

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

STEP 5: Use "Record Snippet"


STEP 6: Execute test suite/test cases

To execute a test suite via command line:

"C:\Squish\bin\squishrunner" --testsuite C:\test_suites\suite_v1
In cmd.exe or Unix shell (adjust paths and parameters as required)

To execute selected test cases via command line:

"C:\Squish\bin\squishrunner" --testsuite C:\test_suites\suite_v1 --testcase tst_case1 --testcase tst_case5
In cmd.exe or Unix shell (adjust paths and parameters as required)

Troubleshooting

Make sure that you have started your application successfully with startjavaaut.