Data Source Test Step

Applies to ReadyAPI 3.56, last modified on November 15, 2024

About Data Source test step

The Data Source test step retrieves data from different sources to use it in data-driven tests.

The Data Source test step allows you to read data from different data storages (Excel sheets, databases, text files, and so on), or generate them during the test run, and then provide them to other test steps as properties of the Data Source test step. You can configure the test step automatically, and it will generate values for your request parameters.

One test step uses only one Data Source type and gets a value for one or more different properties. ReadyAPI supports the following data sources:

Data Source Description
Data Connection Gets data from a database by using a JDBC connection. It is similar to JDBC Data Source, but uses the connection that is shared among the project.
Data Generator Generates test data using a number of built-in data generators.
Directory Iterates through the specified directory and gets file content.
Excel Gets data from an Excel sheet.
File Obtains content of the specified file line by line.
Grid Returns data specified in the Data Source editor’s grid.
Groovy Generates data by using a Groovy script.
JDBC Gets data from a database by using a JDBC connection. Unlike Data Connection, this data type uses the connection specified only for the test step.
JSON Parses the desired data from the JSON content by using JSONPath.
Tip: To learn more about the JSONPath syntax, see JSONPath Reference.
XML Parses the desired data from the XML content by using XPath.

When the test is executing the Data Source step, it reads all the available data and assigns the value of the first data row to step properties.

To iterate through the data rows, you need to add the Data Source Loop test step.

Requirements

To use this test step, you need a ReadyAPI Test license. If you do not have it, you can request it on our web site or start a trial.

Editing Data Source test step

After the creation, you can modify test step settings: select the Data Source type and specify the test step’s properties.

DataSource test step editor

Click the image to enlarge it.

Here is a brief description of available panels in the test step editor:

Properties panel

Shows the list of step properties. The Data Source test step reads data from a data source into these properties (the first read values go to the first property on the list, the second value – to the second property, and so on).

To manage the list, use the toolbar items:

  • – Adds a new property to the end of the list.

  • – Removes the selected property.

  • – Loads the list of properties from a file.

  • – Clears the list of properties.

  • – Renames the selected property.

    Note: When renaming a property, you cannot just change the letter case, for example, renaming Prop1 to prop1. This restriction is imposed by certain databases that have a case-insensitive naming policy and regard such names as identical.
  • and – Move the selected property up and down in the property list.

Also, you can import a list of properties from a file.

Configuration panel

In this panel, you can select the Data Source type and connection parameters.

Data log

In the Data Log panel, you can preview retrieved values.

Property list

Besides the test step editor, you can adjust the test step’s behavior by using its properties in the Data Source Properties and Custom Data Source Test Step Properties panels in the Navigator.

Name Description
Name

The test step’s name.

Description

Text describing the test step.

Data Source Type

Shows the selected type of the data source.

Records Per Iteration

Shows how many rows the data source loads for each iteration. You can change the value in the test step’s options.

Complete Last Operation

Shows whether ReadyAPI will perform the iteration even if the number of remaining rows in the data source is less than the number specified in the Rows Per Iteration option.

This page contains properties that you created in the test step editor. You can use the tab’s toolbar items to create and delete properties, save them to and load them from a file. To learn more, see About Properties.

Test step toolbar

The test step toolbar contains commands that allow you to modify a test step:

DataSource test step toolbar

Click the image to enlarge it.

Here is a description of some commands:

  • – Retrieves data from the specified data source. You can use this item to check if you specified connection settings correctly.

  • – Removes the retrieved data from memory and clears the Data Log.

  • – Opens the Options dialog to configure the test step properties.

Data Source test step options

Data sources have some configurable options for ways to handle data.

To open the Options dialog, click on the test step toolbar.

The options apply to the selected Data Source test step regardless of the data source type.

Options are organized into three tabs:

Settings

The Setting Tab

The tab contains the following options:

Option Description
Restart on Run If this option is enabled, the iterator of the data source is set to the first row every time the test run reaches the beginning of the data source loop. This happens, for example, when you restart a test run or when the data source loop is nested inside another data source loop.
Preload If this option is enabled, the test step tries loading the data from the data source before running the test case.
Fail on Empty If this option is enabled, the test step fails if the data source is empty.

Use this option to create data-driven assertions, if, for example, the SQL query of JDBC data source contains a WHERE clause that uses Property Expansion to select data corresponding to a previously returned response.

Skip Loop on Empty When this option is enabled and the data source is empty on initial execution, ReadyAPI continues test execution from the first corresponding Data Source Loop test step in a test case.
Start Row A zero-based index of the initial row that the data source uses.
End Row A zero-based index of the last row that the data source uses.
Rows Per Iteration Specifies how many rows the data source loads for each iteration. The minimum value is 1.
For information on how to refer to a specific row, see Obtain Property Values of the Specific Row.
Run last iteration When this option is enabled, ReadyAPI will perform the iteration even if the number of remaining rows in the data source is less than the number specified in the Rows Per Iteration option.

For example, if you get two rows in each iteration and the data source has three rows, at the second iteration only one row will remain. When the option is enabled, ReadyAPI performs the iteration. Otherwise, it exits the data source loop and continues the test.

Data processing

Data Processing Settings

The tab contains the following options:

Option Description
Trim Specifies whether the test step will remove leading and trailing spaces from the retrieved text values.
Entitize Specifies whether the test step will replace special HTML symbols (like & or >) with the appropriate entities (like & or >).
Expand If selected, the test step will expand property expansion expressions in retrieved values.

Load testing

Load Test

This tab contains options that control the Data Source test step’s behavior during a load test run:

Option Description
Shared Specifies if the data source is shared between concurrent virtual users.

Enable this option to command virtual users to use the same data source iterator. The test step will move the iterator to the next row every time some virtual user reads data from the data source. So, the next virtual user will use data of the next row.

If the option is disabled, each virtual user has their own iterator and moves through the data source independently from other virtual users.

Restart Shared Works only if the Shared option is enabled. Specifies whether the test step will reset the data source’s iterator when it reaches the last row. If the option is disabled, and the iterator is beyond the last row, then --
  • The Data Source test step returns empty values in its data properties.

  • The Data Source Loop test step that uses this Data Source considers the Data Source to be over. The Test Case execution continues with the test step that is after the Data Source Loop test step.

Stop on Data Source exhaustion When checked, the corresponding Load Test will be stopped as soon as the corresponding Data Source is exhausted (once all the data source’s data items were used).

To access these options in ReadyAPI Performance, select the needed step on the step list:

API load testing with ReadyAPI: Setting up a data source

Click the image to enlarge it.

Logging

While the test step editor is open, you can see retrieved values in the Data Log panel. If the test step is run as part of a test case, you can see brief information on the test step run in the Transaction Log panel.

Working with

Below, you can find information on common tasks that you can perform with the Data Source test step.

  1. Click and specify the needed file. You can select .XLS, .XLSX and .CSV files.

  2. On the next dialog, specify parameters of the import:

    • If you select a .XLS or .XLSX file, specify the name of the desired worksheet and the starting cell.

    • If you select a .CSV file, specify a separator and the desired row.

  3. ReadyAPI generates a list of properties specified in the file.

  1. Select the Data Source type from the Data Source drop-down list.

    ReadyAPI will display the data source properties in the Configuration panel.

  2. Configure the properties to specify connection parameters and other settings.

    The parameters differ from one data source type to another. For detailed information, see Data Source Types.

To command a Data Source test step to load several rows in one iteration, do the following:

  1. Open the Data Source Options dialog and select the Settings tab.

  2. Specify the desired amount of rows in the Rows per Iteration box.

If the total number of the data source rows is not a multiple of the specified value, then, during the last iteration, there rows to be filled with data will not be enough. The Run last iteration option controls what ReadyAPI should do in such cases. If the option is enabled, ReadyAPI runs the iteration anyway. Otherwise, it exits the Data Source loop and continues the test.

During the test, the Data Source test step loads the specified number of rows in each iteration. To refer to a specific row, use the following property expansion syntax:

${DataSouceTestStep#DataSourceProperty::RowNumber}

Where:

  • DataSourceTestStep – Specifies the name of the desired Data Source test step.

  • DataSourceProperty – Specifies the desired property of the test step.

  • RowNumber – Specifies a zero-based index of the desired row.

If a data source gets multiple rows, and you do not specify RowNumber, the expression returns the last received row.

Example

See Also

JDBC Request Test Step
Data Source Loop Test Step
Data-Driven Testing Tutorials
Prepared Properties
Load Testing
Test Steps

Watch the video
 
Highlight search results