A simple way to get started with testing your application with Squish is to record interactions with your application which correspond to the functionality you want to exercise. Once the recording is complete, Squish generates a test script in your preferred scripting language, containing those actions you performed on your Application Under Test (AUT). For every object with which you interact, Squish generates a property-based object name that is associated with a symbolic name. The test script displays the symbolic names, while the object names are stored in a repository referred to as the ‘Object Map’. Upon replay of your recorded session, the exact actions you recorded are performed on your AUT.

It’s easy to imagine that, with longer recording sessions, your test script could end up becoming a large wall of script code, eventually leading to difficulties in reading and maintaining the script. To overcome these issues, you may want to refactor your code. That is, you will want to create functions where necessary and perhaps add more meaningful object names and variables in the recorded script. 

What is Refactoring?

Generally, refactoring operations are features of an IDE that require some knowledge of the programming language structure, and how/where symbols are defined or used. Some language-smart IDE navigation features also fall under this category.

Refactoring is a code improvement method that restructures your code such that it becomes cleaner and simpler, without changing the external functionality of your test case. It allows for improved readability and easier maintenance of your script. Refactoring is best done as a step by step process and should ideally be done on tested code so that nothing breaks. It is possible that upon refactoring, some bugs might become evident. For example, when a large complex function is split into smaller, simpler functions, the design becomes easier to understand, and thus makes the detection of bugs easier. This approach to splitting a large function into smaller functions allows for code reusability, as smaller independent functions can be easily shared among other test cases or across test suites. 

Here are some features offered by the IDE that make refactoring easier:

Jump to Definition/Declaration

For most languages, holding the CTRL while hovering over a symbol turns it into a clickable hyperlink. With this, you can easily jump to a definition with Ctrl+Click. If you are using Perl, F3 is used instead, and the action is called Open Declaration.

When using this on script-based object names, this will open the correct line in (or js, tcl, rb, pl) file. If you wish to see an object name’s definition in the graphical Object Map Editor instead, you can right click on the variable and Open Symbolic Name.

Creating functions from the existing script code

  • Select the code you want to create the function for
  • Right-click, and from the context menu choose Refactoring | Extract Method…

  • In the ‘Extract Method’ dialogue, enter a relevant name for the function.
  • The function will be created and called in your test script.

Here is a YouTube video tutorial that demonstrates this feature.

“Extract Method” is not supported in Ruby and not working in JavaScript.

Renaming variables

Rather than relying on the names generated by Squish, you have the possibility to rename the symbolic names to more meaningful ones. This will also change all existing and future instances of that object name.

  • Select the name of the object you want to change
  • Right click and from the context menu select Refactoring | Rename…
  • In the ‘Rename’ dialogue write the new name of the object
  • After clicking OK, you should see the new name appear everywhere in the script

Renaming symbols is not supported by EPIC (the Eclipse Perl plugin), but it is supported from SquishIDE’s graphical Object Map editor, so renaming object names can be done from any language.

Here is a YouTube video tutorial which demonstrates this feature.


Create variables where necessary

  • Select the string (including the quotes) you want to convert into a variable
  • Right-click, and from the context menu select Refactoring | Extract Local Variable…
  • In the ‘Extract Local Variable’ dialogue check the option ‘Also replace duplicates’
  • Enter the name of the variable

The variable will appear as a part of your script and all references to the string will be replaced by the variable.


This feature is not supported in TCL, Ruby, or Perl.

Conclusion and Additional Reading

SquishIDE, based on Eclipse, supports the most common refactoring features of the underlying programming language plugin you are using for the desired script language. For further information about these plugins, you can follow these links:

The refactoring capabilities of SquishIDE don’t end here. The same can be applied to object-oriented script code and BDD-type test cases.

Leave a Reply

Your email address will not be published. Required fields are marked *

Copy link
Powered by Social Snap