Lesson #6: Streamlining your tests

How to use loops and actions to create tests that are compact, maintainable, and readable.

One key to good testing is to repeat tasks multiple times, supplying the target application with new sets of inputs on each iteration. But clearly, repeatedly entering a set of action lines in a test module is neither an elegant nor practical approach for accomplishing this. Instead, we achieve repetition with loops. With a loop, the same set of action lines can be executed over and over again, with variations of the data or other stimuli that are sent to the AUT. With loops, your tests are far more compact and maintainable.

Another means of creating efficient, maintainable tests is through the liberal use of user-defined actions. User-defined actions are composed of other actions, which may be built-in, user-scripted, or other user-defined actions. They are used to effectively encapsulate what, from a business logic standpoint, may be considered a single task, such as log in or rent a car. User-defined actions, like loops, allow your tests to be more compact, readable and maintainable, and by eliminating redundancy, reduce the time required to write tests.

Audience: Testers, Automation engineers
Prerequisites:
What you will learn: