froglogic / Blog / Navigate and overlook test script code efficiently

Navigate and overlook test script code efficiently

Creating and maintaining Squish tests requires a fair bit of editing the test scripts. It can become very tedious to navigate in bigger script files with arrow keys or by searching.

In this article I present means to navigate directly to script functions and types. The navigation also provides an overview on the available functions in your script code.

The Outline View

The Outline view is a separate tab that can be attached to one of the sides of the IDE mainwindow. It can be opened using the Window->Show View->Outline menu entry.

Outline View with Python code
Outline View with Python code

The Outline view provides an overview of all the functions and (where applicable) classes available inside the current editor. It dynamically changes its contents to match the active editor. In the above screenshot the Outline view shows the several python functions as well as the imported modules. You can select any one of the entries to  move the cursor in the editor window to the start of the corresponding function or the import line.

There are several options for sorting and filtering the view as well as hiding certain bits of information available from the toolbar as well as the dropdown menu.

The Quick Outline View

The Quick Outline view is very similar to the Outline view, it shows mostly the same information. The main difference is that the quick outline view pops up on top of the editor upon pressing a keyboard shortcut (Ctrl+O or Cmd+O on macOS). You can then filter the list of items and press return to quickly jump to the selected entry.

Quick Outline with Python code
Quick Outline with Python code

This provides a very fast and elegant way to jump between different functions or classes within a single file. Its not necessary anymore to scroll around in a file to find the right place to adapt since you can directly jump to the function you need to edit.

The Open Resource dialog

A third quite useful helper in the IDE for navigating around in the test scripts is the Open Resource dialog. It is also triggered through a keyboard shortcut (Ctrl+R or Cmd+R on macOS) and opens up a small dialog to select a different file to be opened from the testsuite or shared script folders.

Open Resource Dialog
Open Resource Dialog

The dialog opens up with a filter field focused that allows you to type part of the file name to reduce the number of displayed items. The filter field also supports using wildcards in case parts of the filename are not known, as shown in the explanatory label above the field.

When selecting a file to open, the dialog reuses an already existing editor tab for that file, if the file was already open. So the same shortcut can be used to switch between already open files without having to cycle through a long list of open editor tabs.

Further reading

There are quite some more shortcuts available for navigating around in the IDE that make it easy to keep the fingers on the keyboard. You can find an extensive list in our documentation and all of them can be configured to your liking on the Keys Pane in the Preferences dialog.

For navigation purposes the shortcuts to switch to the next and previous editor (Ctrl+F6 and Ctrl+Shift+F6 or Cmd+F6 and Cmd+Shift+F6 on macOS), the one to open the declaration of a function under the cursor (F3) and the shortcut to activate the editor area (F12 or Cmd+F12 on macOS) are likely the most interesting ones.

Depending on the script language being used, there are other views and functionalities offered, for example with Javascript, its possible to use the Call Hierarchy view to see which functions a given function is being called from. Many languages provide a way to look at the hierarchy of classes with a Type Hierarchy or Hierarchy view. All of these views can be found through the Open View dialog which is opened with the Show View action.

Leave a Reply

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

Copy link
Powered by Social Snap