12.1. Creating a Test Suite

A test suite is a collection of one or more test cases (tests). Using a test suite is convenient since it makes it easy to share tests scripts and test data between tests.

Here, and throughout the tutorial, we will start by describing how to do things using the IDE, with the information for command line users following.

To begin with start up the IDE, either by clicking or double-clicking the squishide icon, or by launching squishide from the taskbar menu or by executing squishide on the command line—whichever you prefer and that is suitable for the platform you are using. Once Squish starts up it will look similar to the screenshot—but probably slightly different depending on the windowing system, colors, fonts, and theme that you use, and so on.

The Squish IDE with no Test Suites

Once Squish has started click File|New Test Suite... to pop-up the New Test Suite wizard shown below.

The New Test Suite wizard's Name & Directory page

Enter a name for your test suite and choose the folder where you want the test suite to be stored. In the screenshot we have called the test suite suite_tcl and will put it inside the addressbook folder. (For your own tests you might use a more meaningful name such as "suite_addressbook"; we chose "suite_tcl" because for the sake of the tutorial we will create several suites, one for each scripting language that Squish supports.) Naturally, you can choose whatever name and folder you prefer. Once the details are complete, click Next to go on to the Toolkit (or Scripting Language) page.

[Note]Note

Different versions of Squish support different toolkits—if your version only supports one toolkit, this page may not appear, and you may be taken directly to the Scripting Language page instead. And if you do get this page, the toolkits listed on it might be different from those shown here, depending on what options you built Squish with.

The New Test Suite wizard's Toolkit page

If you get this wizard page, click the toolkit your AUT uses. For this example, we must click Tk since we are testing a Tk application. Then click Next to go to the Scripting Language page.

[Note]Note

Squish supports several different scripting languages, and different installations may include support for some or all of these—so the scripting languages shown in the screenshot may be different from those shown by your version of Squish.

The New Test Suite wizard's Scripting Language page

Choose whichever scripting language you want—the only constraint is that you can only use one scripting language per test suite. (So if you want to use multiple scripting languages, just create multiple test suites, one for each scripting language you want to use.) The functionality offered by Squish is the same for all languages. Naturally, if you are a Tcl/Tk programmer, Tcl will be the best choice, but if you are new to scripting, Python is the easiest to learn and use, and arguably the best for readability and maintenance. Having chosen a scripting language, click Next once more to get to the wizard's last page.

The New Test Suite wizard's AUT page

If you are creating a new test suite for an AUT that Squish already knows about, simply click the combobox to pop-down the list of AUTs and choose the one you want. If the combobox is empty or your AUT isn't listed, click the Browse button to the right of the combobox—this will pop-up a file open dialog from which you can choose your AUT. Once you have chosen the AUT, click Finish and Squish will create a sub-folder with the same name as the test suite, and will create a file inside that folder called suite.conf that contains the test suite's configuration details. Squish will also register the AUT with the squishserver. The wizard will then close and Squish's IDE will look similar to the screenshot below.

The Squish IDE with the suite_tcl test suite

We are now ready to start creating tests. Read on to learn how to create test suites without using the IDE, or skip ahead to Recording Tests and Verification Points (Section 12.2) if you prefer.

[Note]For command-line users

To create a new test suite from the command line, three steps are necessary: first, create a directory for the test suite; second, create a test suite configuration file; and third, register the AUT with squishserver.

  1. Create a new directory to hold the test suite—the directory's name should begin with suite. In this example we have created the squish/examples/tcl/addressbook/suite_tcl directory for Tcl tests. (We also have similar subdirectories for other languages but this is purely for the sake of example, since normally we only use one language for all our tests.)

  2. Create a plain text file (ASCII or UTF-8 encoding) called suite.conf in the suite subdirectory. This is the test suite's configuration file, and at the minimum it must identify the AUT, the scripting language used for the tests, and the wrappers (i.e., the GUI toolkit or library) that the AUT uses. The format of the file is key = value, with one key–value pair per line. For example:

    AUT      = addressbook.tcl
    LANGUAGE = Tcl
    WRAPPERS = Tk
    

    The AUT is the Tk executable. The LANGUAGE can be set to whichever one you prefer—currently Squish is capable of supporting Python 2, Perl, JavaScript, and Tcl, but the precise availability may vary depending on how Squish was installed. The WRAPPERS should be set to Tk.

  3. Register the AUT with the squishserver. [10] This is done by executing the squishserver on the command line with the --config option and the addAppPath command. For example, assuming we are in the squish directory on Windows:

    squishserver --config addAppPath squish\examples\tcl\addressbook
    

    Naturally Mac OS X, Unix, and Linux users would use / instead of \ as their directory separator.

    The path is to the executable that was added as the AUT in the test suite configuration file. (For more information about application paths, see AUTs and Settings (Section 16.4) in the User Guide (Chapter 15), and for more about the squishserver's command line options see squishserver (Section 16.5.2) in the Tools Reference Manual (Chapter 16).)

We are now ready to record our first test.




[10] Each AUT must be registered with the squishserver so that test scripts do not need to include the AUT's path, thus making the tests platform-independent. Another benefit of registering is that AUTs can be tested without the Squish IDE—for example, when doing regression testing.