Ask a Question

Data driven testing - How to create and use a table data source with a groovy script?

Frequent Contributor

Data driven testing - How to create and use a table data source with a groovy script?

In ReadyAPI, I want to create a "table" of test data by using a Groovy Script block inside a Data Source block. I will generate the data for the "table" with custom logic/code. The "table" can have multiple columns and each row represents a set of test data.

I want to use the "table" in a data source loop & make a REST API call inside the loop. The API call should be able to access all the columns inside each row. To summarize, think of this as a groovy script which provides DataGenerator + Grid data sources.

So, how do I generate a table of data with a Groovy Data Source? Is there a recipe for this?

Keywords - data driven tests, Data Source, tabular test data, test data table.

Community Leader


The licensed version of SoapUI/ReadyAPI does this out of the box and does it very well.  It's probably my favourite feature.


If you're using the open source version it can be achieved, but takes a bit of effort.  There are plenty of recipes/solutions on this forum and Stack Overflow which describe this how to do this.  I'm not going to link any particularly solution as its worth it to you to look at a couple of different solutions so see how this can be achieved.


Good luck,



Frequent Contributor

I could not find any recipe or answer for my problem on this forum and also on stack overflow. In this forum I searched "groovy data source". In stack overflow, I searched "ready-api groovy data source" & "[ready-api] groovy data source". I could not find any posts which provide hints or a recipe.


So, do you know any better keywords to search or a solution to the problem?


Hey @rajs2020,

Youre using ReadyAPI!, right?

Doesnt a datasource grid type get you some of the way there? If you want a table of data, a datasource step of grid type may help


if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Community Leader

Hi @rajs2020,


I read your question incorrectly.  Thanks to @richie, I read it again. 


So, you have Ready API and with that you have Data Driven Tests?  It sound like you want to generate data on the fly AND use it as a source for your data driven test at the same time?  Am I getting closer?



Frequent Contributor

Yes, I want to create my own "table"/"data grid" with code and then use its data to make some api calls repeatedly. I do not want to use the static/fixed data grid of ReadyAPI. Thanks.

This is the kind of code I expect:
"Table" tab = new Table()
//Code to fill the table.

Table tab = DataSource.getResult();
FOR each row, iterate through columns & use column values in to make api call in REST api step.

Why not an initial Groovy step that creates the data for the test and saves it to a file.  Then use plain old Data driven tests to read the data from the newly created file.

You don't have to use Ready API/Groovy to create the data, you could use whatever you want, but I suppose it would be tidier all in Ready API. 


Re "FOR each row, iterate through columns & use column values in to make api call in REST api step.", are you trying to make something truly dynamic that can fit any number of rows and columns?  If so, how are you going to build your payload based on the columns in the row?

Frequent Contributor

Thanks. But, I don't want to create a file because it is unnecessary overhead & I only need to create 5-10 rows of data. ReadyAPI has its own data grid. I wonder if the code for that is available inside groovy script so that we can generate the grid ourselves too.

For the 2nd part, this is what I have in mind - The number of rows & columns are known, all rows must have the same number of columns and the table supports at least, say 100 rows (arbitrarily chosen). I haven't figured out how to build the api payload yet. I'm almost about to abandon this approach & let duplicate tests remain.

Showing results for 
Search instead for 
Did you mean: