Lesson 5: Modularize the test script

In this tutorial, you recorded a test scenario in which you signed in to the web site, browsed for a product, and saw pricing details. In the actual scenario, you would have also recorded how to purchase, check out the product, and sign out of the website. You would have done that to avoid recording the same application multiple times. However, maintaining a big test script with a lot of data can be difficult. After the recording, you can modularize the test script by splitting it at appropriate steps and thereby creating meaningful chunks of test scripts. For example, for the test scenario in this tutorial, you can split the ‘Sign in’ and ‘Choosing the product’ steps and create two test scripts out of it. You can then add these scripts to a Compound Test to run in sequence.

Procedure

To modularize the test script:

  1. Select the steps from ‘Click on Edit text … where you entered ‘rational test workbench’ in the Search field to Close browser window in the test script, both inclusive.
  2. Right-click the selection and click Split Mobile or Web UI actions. Split test script
  3. The Refactoring test window opens. On the right side of the Refactoring test window, under After Refactoring, examine the changes to be performed as a result of the split. Then, click Next. The selected steps are added to a newly created node called the In application.
    Split test script

    You will now add the steps that are in the In application node to a new test script.

    To create an empty test and copy these steps to it, proceed as follows:
    • 1. Click File > New > New Test.
    • In File name, type ibm-web-purchase and click Next.
    • In Description, type Test script to purchase and click Next.
    • Select the Mobile and Web UI Feature check box and click Finish.
    • From the ibm-web test script, right-click the In application node and click Cut.
    • In the ibm-web-addtocart test script, right-click the root node and click Paste.
    • Click File > Save.

Results

You have now moved the Choosing the product test steps from ibm-web test script to ibm-web-purchase. Note that you cannot run the ibm-web-purchase test script independently. You can run it only as part of a compound test.

Now, you will create a datapool and add data that will be used by the test.

Feedback