Chapter 6. Tutorial: Creating the First Test with Squish for Qt

Table of Contents

6.1. Creating the First Test
6.1.1. Creating a Test Suite
6.1.2. Recording a Test Case
6.2. Inserting a Verification Point
6.2.1. Inserting a Verification Point
6.2.2. Test Results
6.3. Creating a Data-Driven Test
6.4. Using a Different Scripting Language
6.4.1. Using JavaScript
6.4.2. Using Tcl
6.4.3. Using Perl
6.5. Conclusion

This chapter walks you through the whole process of taking an existing Qt application, making it testable and creating tests for it. At the end we have a test suite which can be used to ensure the correct behavior of the application.

This chapter presents all the major concepts behind Squish and provides the information you need to get started using Squish for testing your own applications. This tutorial does not discuss all features of Squish in detail. After reading this tutorial we suggest to continue with the User's Guide (Chapter 18).

The tutorial is divided into several sub chapters. If you are new to Squish, you might want to walk through all of them. If you are already using Squish you might want to just pick the sections about new features you haven't used before.

For this chapter we use the address book example which is shipped together with the Qt 3.x package. You can find a copy of it in squish/examples/qt3/addressbook. This version is compatible with Qt 3.x and Qt 2.x/Embedded. If you are using Qt 4.x, you can find a Qt 4 port of this example in squish/examples/qt4/addressbook.

There are no fundamental differences between testing a Qt 3 or Qt 4 application. There are some differences in the resulting test scripts and the look of Squish's IDE. This tutorial mentions the differences and covers testing Qt 3 and Qt 4 applications.

The address book example is a simple application that allows adding and modifying address records, saving and loading addresses in a text file and searching the address book.

But before we will make this application testable, it might be useful to have a look of how Squish works. Please see Concepts and Making an Application Testable (Chapter 5) for further information.