Using External Tools in the Squish IDE

Using External Tools in the Squish IDE

The Squish IDE supports opening the files shown in the « Test Case Resources » and « Test Suite Resources » with external tools. This works by associating file content types or a file extension (for example « .txt ») with one or more applications, tools, shell scripts, etc.

These associations can be edited at Edit > Preferences > General > Editors > File Associations:

Once an « editor » is added for a file type/extension, the context menu of such files contains a respective entry:

Simple Use Cases

At first glance it does not seem very exciting to be able to open external tools for files with specific file extensions like this – although it may be appealing to use Microsoft Excel or LibreOffice Calc for editing .csv, .tsv and .xls data files.

We could, however, use this functionality to open a tool that extracts a call stack/backtrace from « core » files directly from the Squish IDE. (These are files which may be generated when the Application Under Test crashes. For example with a shell/Python script such as this:

#!/usr/bin/python
# -*- coding: utf-8 -*-


import os
import subprocess
import sys


fn_binary = subprocess.check_output(['file', sys.argv[1]]).split('execfn: \'')[1].split('\'')[0]
fn_backtrace = "%s.txt" % sys.argv[1]

args = ['gdb -ex "bt full" -ex q "%s" "%s" >"%s" 2>&1' % (fn_binary, sys.argv[1], fn_backtrace)]
print "%s" % args
subprocess.Popen(args, shell=True).communicate()

if sys.stdout.isatty():
    os.system('cat "%s"' % fn_backtrace)
else:
    if os.system('gedit "%s"' % fn_backtrace) != 0:
        os.system('geany "%s"' % fn_backtrace)

More Complex Use Cases

However, more advanced uses cases are possible, for example, for workflows similar to what we are already using for verification points in Squish. For those, the workflow usually is like this:

  • Create a verification point.
  • Execute the verification point,
  • In case of a failed verification point, view the differences, and decide whether to adjust the expected results and/or to fix the test execution.

In the last point, we may be using one of Squish’s built-in tools for viewing the differences. For example for a table verification point, the Squish IDE shows the differences in an internal difference viewer. And for an image verification point Squish uses a viewer specialized on showing image differences.

In the case of our own, custom verifications, which read the « expected » data from a file (which – granted – may be an advanced thing) and compare the data to the contents of a GUI control, one would usually log the differences to the test report/results via test.pass(), test.fail(), etc. If the « actual » data found in the GUI control is also written to a file, we can also use an external tool for comparing the « expected » data file to the « actual »/ »failed » data file.

And at this point the above mentioned functionality makes it very convenient to open the « expected » and « failed » data file in a tool of our choice (for example text file diff/merge tools like Meld, WinMerge, and others).

Example in the Knowledge Base

An article that shows an example implementation of this can be found in our knowledge base at Custom, File based Verification Points. This is what the user sees after choosing Open With… > View differences as described in that knowledge base article:

At this point one can update the « expected » data (on the left) via copy & paste, or by using the functionality provided by this particular diff tool (arrow buttons pointing left).

0 Avis

Laisser une réponse

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

*