Assigning test variable values from a dataset by using the Assign step
You can assign values from a dataset to test variables by using the Assign step. This supports dynamic data substitution during test execution, allowing subsequent steps to use unique and data-driven values.
Before you begin
- Ensured that you are assigned a Team Space Owner, Project Owner, or Member with a Tester role to create or edit a test resource.
- Read and understood the information in Edit branch overview and Create or select an Edit branch.
- Ensured that your project contains a Web UI test or suite.
- Ensured that the required variables have been created and are included in your Web UI test or suite.
- Ensured that your project contains a dataset.
About this task
You can create datasets in Test Hub and assign their values to variables in a test. This process helps you to run data-driven tests consistently with parameters and reduces the need to repeat steps. Dataset values are mapped to variables in a test, to perform flexible data-driven testing across multiple scenarios.
Procedure
-
Click the
button displayed on the Test
Editor page.
The Edit button appears only when no active edit branch is selected.
Alternatively, right-click the test in the test navigator panel and select Edit.
The Edit branch dialog is displayed.If the Edit branch dialog is not displayed, then go to step 3.
- Select an existing branch or create a new branch.
-
Drag the Assign statement from the pane and drop it under a test step as required.
The Assign step is inserted.Note:
You can also use the Assign step within a while or do-while step, so that the Assign step retrieves the values from a dataset to process each row of the dataset iteratively and assign the retrieved values to the test variables.
-
Click the Assign step.
The step details pane opens with the Details tab which was the default selection.
- Select an existing dataset in the Dataset field.
- Click Add to add a variable and assign the value from dataset.
-
Select an existing variable from the Select a variable to
assign drop down.
Note:You can also select Add new variable from the list to create a new variable and assign the value from the dataset.The variable is displayed in the Variables section.
-
Click the drop-down icon
in the variable.
The variables in the test and column names in the selected datasets are listed. - Select the column in the dataset from which you want to assign the values during test run.
-
Click Close icon
to close the run details pane.
-
Click the Save icon
to save the
modifications.