Squish/Best Practices

From Qt Wiki
< Squish
Revision as of 15:00, 14 January 2015 by Maintenance script (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

this page in: Español

The recommended way of working with Squish

Imagine you have been using Squish out-of-the-box for a while, recording and replaying test
cases with none or only minor manual modifications to the test scripts. You have reached a significant
amount of test cases, and most of them start with doing the same sequence of steps, e.g. logging in to
a remote server by specifying a user name and a password and then clicking OK in a dialog.

The code for this could look something like below:

Now imagine, for some reason, a developer goes and changes your application to not use a line edit as the
user name input field, but a QComboBox instead. Now you will need to go and manually re-record or at least
change every single test case interacting with this login dialog.

Instead of creating test cases by simply recording them, as that would eventually lead to the problem above, the
recommended way of working with Squish is to record and refactor. That is, you record a test case, or a piece
of a test case, and refactor that into one or several functions that you then call from your test script.

In the example above, you would create a login() function after you have recorded the first test case that
involves logging in to a server. Then for all subsequent test cases, you call this login() function from
your test script. In code, this would be:

And as a side-effect of us creating this method, we also parameterized the function call, so you can test
the login dialog with different values by just adding additional calls to login().

If the same change to the application as above would now be made by a developer, you would not need to change hundreds of test
cases manually, but only one single function.

There are 2 articles in "Tools -> Squish -> RecommendedWayOfWorking":

T

Categories: