Lesson 9: Adding a loop
You can learn about adding a loop to a test so that the test runs repeatedly for a specified number of time, while fetching values from an associated dataset. You can either select a count-based, a time-based, or an infinite loop for the test. You can set the loop to infinite if you want the test to fetch the data from all the rows in a dataset.
Before you begin
You must have completed the following tasks:
- Read and been familiar with running tests. See Lesson 3: Running a test.
- Read and been familiar with adding a loop to a test. See Adding a loop.
- Associated a dataset with the test. See Lesson 7: Associating a dataset with a test.
- Ensured that the WikiCompoundTest test is displayed in the Compound Test Contents panel of the test editor window. See Lesson 8: Creating a compound test.
About this task
For the test scenario in this tutorial, you can use AnimalsDataset as the associated dataset that has three entries. You can add a loop with three iterations to the test.
Procedure
-
Select the wiki-search-animals test in the Compound Test
Contents panel, and then click .
The New Loop dialog is displayed.
-
Click Yes to move the wiki-search-animals
test to a new loop.
The wiki-search-animals test is displayed within a loop in the Compound Test Contents panel.
- Enter wiki-loop as the loop name in the Loop Details panel.
-
Select the Count-based option, and then enter 3
in the iterations field.
- Click to save the changes.
-
Click Run Compound Test to run the test.
The Confirm Perspective Switch dialog is displayed.
- Click Switch to run the test in the Test Execution perspective.
- Select Chrome in the Run Configuration dialog.
-
Click Finish.
The compound test run begins. The wiki-search-animals test runs three times while fetching the data from the AnimalsDataset dataset.
Results
You have learned to add a loop to a test so that the test runs repeatedly for a specified number of time.
What to do next
- The associated dataset is successfully applied for the search action during the playback.
- The animal name in the test is substituted with the animal names that are listed in the dataset.
- The test is successfully repeated for the specified number of iterations.