< Previous | Next >

Lesson 7: Enhancing the test with a loop and a datapool

After you record and then run a test, you can enhance it, using the test editor in the IBM® Rational® Test Workbench Eclipse Client.

In this lesson you will learn how to make the following edits to the recorded test:

After completing these steps, you can run the test to see it iterate multiple times using the loop and the data in the datapool.

  1. Start by opening the test that you recorded in Lesson 4: Recording a test and enhanced in Lesson 6: Creating a verification point. If the test is not already open, double-click the test in the Test Navigator to view the test in the test editor.

    If you used the UICatalog application to record the test, the Test Contents window looks like this:

    Generated test

  2. Add a loop. With a loop, you can specify that the test will run a specified number of times or for a specified period of time.
    1. Right-click the first step in the test, Launch application UICatalog 2.10 and select Insert > Loop.
    2. When you see the prompt, Would you like to move selected objects into New Loop?, click Yes.

      The loop is added to the test as shown below:

      Loop shown in Test Contents

    3. In the Loop Details section to the right, change Count-based to 3 iterations.

      Count-based duration

    4. Verify that the device is still in passive mode and then click Run Test. If the device is not in passive mode, tap Enter Passive Mode on the device.
      Note: At the beginning of each loop, you might be prompted on the device to open a page in the UICatalog app. If you see this prompt, click Open.
    5. Verify that the entire test runs three times.
  3. Now, try changing the text in a text field.
    1. In the User Action Details section, replace the text in a Text field. For example, in the Object Actions row, change the word Hello to the word Greetings, and then click File > Save.
    2. Notice the change in the Test Contents on the left.
    3. Run the test.
  4. Now, add a datapool. Datapools provide tests with variable data during a test run.

    When you record a test, you perform a sequence of steps that you expect a typical user to perform. From the recording, a test is generated that exactly captures these interactions. When you run this test, it uses the same data that you used during recording. To vary the data in the test, you use a datapool, in which variable data is substituted for the data in the recorded test.

    To create a datapool:

    1. In the Test Navigator view, right-click the UICatalog project and click New > Datapool.
    2. In Name, type UICatalog_text and click Next.
    3. Type a Description for the datapool
    4. In Variables (or columns), leave it as 1.
    5. In Records (or rows), type 3 and click Finish.

      New datapool

    6. Click Yes to open the datapool editor.
    7. In the datapool editor, click Variable1:String and change the column name to Text_String.
    8. Click each cell and enter data so that the datapool looks like this:
      Datapool editor
    9. Click File > Save.
  5. After creating the datapool, update the test to include a reference to the datapool.
    1. Right-click the name of the test in the Test Contents window and click Add datapool.

      The Select Datapool File window opens, as shown below:

      Select Datapool File

    2. In the Select Datapool File window, select the datapool and click Finish.
    3. Click File > Save.
  6. After adding a reference to the datapool, you then substitute the actual value that you used in recording with the ones from the datapool.
    1. Navigate to the step in the test where you plan to add the datapool, in this case the Enter text "text" in Text field step.
    2. In the User Action Details area, right-click the actual text in the Text field and click Substitute > Select Data Source.

      The Select Data Source window opens.

    3. Select the test and click Select. If you are prompted to substitute for more values, click No.

      The text in the Text field changes color.

    4. To save the changes, click File > Save.
  7. Run the test.

    The test should now run three times. The first run should use the text in row 0 - ABCD and test alphabetical characters; the second run should use the text in row 1 - ABCD1 and test a combination of alphabetical and numeric characters; the third run should use the text in row 2 - 1234 and test all numeric characters.

.

Lesson checkpoint

In this lesson, you learned how to do the following tasks:
  • Change text in a text field
  • Add a loop
  • Add a datapool
  • Reference the datapool in the test
  • Substitute recorded values with the values in the datapool
< Previous | Next >

Feedback