Now that you’ve defined your variables and assigned a data source to the test case, you’re ready to connect them. This step is called data binding. In this article, learn how to map data source columns to variables so each iteration fills the variables with values from the current data row.
Initial situation
The image below shows the initial situation with the data source assigned to the test case and the defined, but unbound variables next to the recording modules.
- Data source myCSVData with 8 data rows assigned to a test case.
- 6 unbound variables in 5 recording modules.
Access data binding
Use one of the following options:
Right-click a test container and click Data binding…
Double-click an unbound variable in the test suite view
The data binding dialog
The Data binding dialog helps you review assigned data and create or change bindings. It contains:
- Data binding tab in the properties window of the test container.
- List of available data columns from the assigned data source.
- Multiple drop-down menus containing the defined variables available for binding.
- Auto-bind function explained at the end of this article.
- Unbinds all variables from their data columns.
Bind data to variables
Binding data means assigning a variable to each data column you need. Each variable can only be bound once, so the dialog displays only variables that are still unbound.
For the column FirstName:
- Open the drop-down list of variables next to the data column.
- Check the variable to which the data is bound. In this case: InsertName.txtFirstName
For the column LastName:
- Open the drop-down list of variables next to the data column.
- Check the variable to use for the data binding. In this case: InsertName.txtLastName
Repeat these steps for the remaining columns/variables.
Result
- List of available data columns from the assigned data source.
- List of bound variables.
Resulting test suite view
After binding, the test suite view reflects that variables are no longer unbound and the container uses the assigned data source for iteration.
- Data source myCSVData with 8 data rows assigned to a test case.
- 6 bound variables in 5 recording modules.
Next step: Your data-driven test setup is now complete. In the next article, learn how to run the test and review the report output.
View status in the data binding pad
The data binding pad gives you a quick and detailed overview of a test container’s data binding, i.e., its variables and parameters, their status, and their values.
- To open the data binding pad, click the View data binding button in the toolbar and select a node (for example, an item) in the test suite.
- The data binding pad displays the data binding information for this node.
Auto-bind
Auto-bind automatically binds variables to data source columns or parameters with the same name.
Auto-bind is available in three places:
In the Data binding dialog
From the test container context menu
When auto-creating a data source from variables
Auto-bind from data-binding pad
To auto-bind this way:
- Select an item in the test suite with unbound, auto-bindable variables.
- Click Auto-bind in the data-binding pad.
Auto-bind from message
When you add or move a module that contains unbound auto-bindable variables, a message pops up to ask you if you want to auto-bind these variables. You can also click Remember selection for this solution to always do so automatically.
Data binding in module groups
Data binding for module groups works a little differently than for test containers (test cases, smart folders).
Initially, variables used in recording modules that are inside a module group are not visible in the test suite view. You can only see them if you open the module group.
- Module group InsertName in the smart folder InsertData.
- The module group contains two recording modules, each with one defined but unbound variable.
- These variables are not yet visible in the test suite view and therefore can’t be used. At this point, they’re only visible inside the module group. They are encapsulated in it.
Bind the variables in the module group to data
To make these encapsulated variables visible in the test suite and bind them to data, we need to first bind them to module-group variables. These act as a bridge from inside the module group to the test container.
To bind variables to module-group variables:
- In the module group view, right-click the module group.
- Click Data Binding…
- Add a module-group variable for each recording-module variable and bind the recording-module variables to the module-group variables.
1. You can also bind the recording module variables to constant values. This way, the variables are not visible/usable in the test suite view, but are still bound to values.
Result
- The variables are now visible through the module-group variables in the data binding pad…
- …and can be bound to data sources and parameters in test containers just like other variables.