Data sources in ReadyAPI are a powerful tool you can use to create data-driven tests. By default, data sources only provide the data they take from the source to any test step that needs it. They cannot modify the data in any way or control it. For this, you use Groovy scripts. This topic provides examples of some ways you can modify your data-driven tests.
There are the following ways to run this script:
As a Groovy Script test step.
As a setup or teardown script on the test case level in functional tests.
The following script gets the values from a project and a data source, combines them to a single string and writes them to the test case custom property.
Most data sources in ReadyAPI return values in sequence. You can use groovy scripts to randomize the order of the returned values each time you run a test. Here is how you organize your test to do this:
The original Data Source test step with the data you want to randomize.
The Groovy Script test step that creates a list with the data from the data source. Use the following script:
The Data Source Loop test step that iterates through the original data source so that you can get all the data it returns.
The Groovy Data Source test step that provides random data to your test. Use the following script:
Your test steps that use the data and optionally a data source loop to iterate through it.
Here is what your test case can look like:
![]() |