Test Templates

This section explains how Badboy allows you to structure your scripts using Templates.

The Need for Test Templates

It is very common to find that many of your tests share a similar pattern. For example, it's very normal for all of your tests to have to first log in to your application and then log out afterwards. Sometimes there can be quite complicated sequences of actions that are common to a whole class of tests. Test Templates are designed to help you with this problem by letting you create the pattern for your test and save it, and then reuse that pattern for all of your Tests that share the same sequence of actions.

If you simply want to reuse one item or a group of items in a Step then you can save the items as an External Tool. The difference between External Tools and Test Templates is that Templates allow you to reuse the structure of a Test as well as the items in it.

Creating Test Templates

You create Test Templates by first creating a Test that matches the structure that you want Tests that use the Template to have. For example, if you want to make Tests that log in, perform a specific action and then log out, you might make a Template in the following form:

Example Login Test

Notice that the Login and Logout Steps in the above example have items recorded in them, but the "Execute Tests" Step is empty. This step is a place holder for where tests that extend your template will place items. Once you have created a Test that matches the outline you want, right click on it and select the "Save as Template" option.

Example Login Test

Badboy will then let you choose a file name and allow you to save the template. The filename you choose should end in the extension ".bxt" (this will be the default if you don't enter an extension).

By default Badboy saves templates in a directory called "Badboy Templates" created in your login user's Documents and Settings folder. However if you want to you can also save the template in the same directory as the script you are creating. This way it will always be easy to find the template file and you can simply zip up the folder if you want top send it to someone else and be sure they get all the templates needed by the script. Badboy will always check both these locations when looking for templates that are referenced in your script.

After you have saved your template Badboy will offer to replace the Test with one that extends the template. If you do this you will see the Test change: all the Steps that were previously in your Test will have changed to a white. These Steps are known as "bind points" as they are "bound" to the template and will execute what is in the template. The figure below shows how the Login Test looks after it has been saved and converted:

Converted Login Test

Notice that the Template that has been extended is shown in angled brackets so that you know it is the source for the Test's bound items. Also note that the Step that you left empty has been automatically made the recording Step - Badboy automatically assumes that empty Steps are meant to be implemented by Tests that extend the Template.

Overriding Steps

It is common that you may find that some of your Tests that extend a Template need to alter one of the Steps that the Template defines. This is known as "overriding" the Template Step because your own Test's version of the Step will execute instead of the Template version. Overriding a Template Step is easy to do - just right click on the Template Step that you want to override and select "Override/Implement" and Badboy will change the Template Step to a normal Step and let you record inside it.


Badboy Documentation Generated on Mon Dec 29 22:28:42 EST 2008