Hidden Squish 4.0 Features: Squish/Mac's Attach To Application

Hidden Squish 4.0 Features: Squish/Mac's Attach To Application

After finally releasing the beta of our upcoming Squish 4.0 release, I decided to highlight some of the less visible, but very cool, Squish 4.0 features. In this post I’d like to talk about the « injectMacWrapper » feature. Until recently it was even unknown to me 🙂

The other day a prospect asked me to present a demo of Squish for Mac to test a well known online meeting software (Cocoa) running on Mac OS X. The challenge here is that the application can’t be started stand-alone, which is usually required so Squish can start it to load the hook into it allowing Squish to connect to the application for testing (listen to events, access objects and properties).

In this case the application can only be started via a web browser when starting a meeting.

So I walked over to Rainer, our Mac expert, if he had an idea how we could support that. And to my surprise, he just pointed me to the example « injection » which can be found in « examples/mac » in Squish 4.0 Squish/Mac packages.

This example basically contains one script which injects the mac wrapper (the Squish hook for Squish/Mac) into a running process and makes the application attachable for Squish that way. Be aware that you have to first open the script and adopt the SQUISH_BASEDIR variable to point to your Squish installation directly. Also you may change the ATTACHABLE_PORTNUMBER if necessary which is the port to which Squish can then connect to attach to the application.

In addition, before starting the application you want to attach to (or the parent process which may invoke it), make sure to set the environment variable DYLD_LIBRARY_PATH to point to the « lib » directory of your Squish package so the Squish libraries will be found.

Now start (or get started) the process you want Squish to attach to later.

Finally run the injectMacWrapper.sh script and just pass the name of the process, as you can find it in the Activity Monitor, as an argument to the script. You will see some output and once it is done, Squish can attach to it at the given port.

Now open the Squish IDE (the new, Eclipse based of course :-)) and go to Squish->Manage AUTs. There add an attachable AUT, choose an arbitrary name and specify the port which you have chosen (or left untouched) in the injectMacWrapper script (specified via ATTACHABLE_PORTNUMBER).

Now you can go ahead and create a new test script and create a skeleton script function such as (assuming JavaScript)

function main()

where AttachApp is the name you specified as name for the attachable AUT in the Manage AUTs dialog.

Now set a breakpoint on the snooze line and execute the script. When you hit the breakpoint, choose recording, record interactions on the running process and choose end recording.

Using the same method you can insert verifications, use the Spy, insert more recording snippets, etc.

Really a cool feature since it allows to attach to processes which have not been started by Squish or been modified for testing (which is many cases just isn’t possible).

A similar functionality is available in our new « Squish for Windows » edition also combine with other Squish editions so one can e.g. automate a Windows GUI started via Click Once from a web site. Of course also Squish for Qt and Java allow attaching to running applications.

I will talk about these features and cross GUI technology testing more in the next postings.

0 Avis

Laisser une réponse

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *