Data driven testing with SoapUI Free version


This tutorial will show you how to use flat files as a data source for data driven testing in FREE version of SoapUI. It is very simplified example which can be improved to fit your needs quite easily. At the and of this tutorial you will be able to run a test suite which is executing one test case 10 times with different values thanks to a CSV file as a data source.

Good to know before we start:



Create project and the test case

First of all we need to have something to test. In this tutorial we will make use of a free temperature convertor available at Now lets get our hands dirty with SoapUI and create a new project. Since we are going to use HTTP GET requests and responses we will create a Generic project:
Project creation
After that we will create new Test Suite as follows (we can keep default name):
Test Suite creation
Now create new Test Case and name it "TempConvert":
Test Case creation
To create our very first Test Step we have to add new HTTP Request (right click in Test Case window):
Test Step creation
Once we did that we have to specify the Test Step name (CelsiusToFahrenheit), Endpoint ( and three paramters (Temperature, FromUnit, ToUnit) as follows:
Test Step setting
Time to try our new test case. if everything was done properly we should see that 30 degrees Celsius is 86 degrees Fahrenheit (quite hot):
Run test case
To make our Test case complete we better add an assertion there. To make it simplier we will just create a "Contains" assertion as follows:
Contains assertion adding
Good, Test Case is ready. Now it's time to run this very same test case as many times as we define in our data file.

Prepare data file

Let's say we would like to test that first 10 degrees Celsius are returned as degrees Fahrentheits properly. For that we will create simple CSV file with first value equal to be degrees to inserted as an input seperated by comma from expected value to be returned by our previous test case. Note that expected value for our seventh input was intentionaly corrupted in order to see a failure during our next steps.
Data file

Read the data file

In order to read through a file in FREE version of SoapUI we will have to do a little bit of scripting. Nothing too complicated but yet powerfull. Before we do that we have to create new test case within our existing Test Suite 1 and name it Iterator.
We don't need a picture here since we were doing the same thing fews steps above. What we need now is to create a Groovy script step as follows (name it ReadInput):
Create Iterator Test Case
If we did everything right we will see an empty Groovy script window:
Empty Groovy script window
Final step requires multiple actions:

// Get tha path to an input file from a custom property
def inputFilePath = testRunner.testCase.testSuite.getPropertyValue( "inputFile" )

// Iterate through the input file
File file = new File(inputFilePath.toString()).eachLine{

// Set Test Suite custom properties
testRunner.testCase.testSuite.setPropertyValue( "inValue", it.split(",")[0] )
testRunner.testCase.testSuite.setPropertyValue( "outValue", it.split(",")[1] )

// Log info to a output "Input value: ${it.split(",")[0]}; exptected value: ${it.split(",")[1]}"

// Sleep for a second since weare using public service
sleep 500

Our Groovy window should be similar to this one now:
Read data file

Data driven test execution

Very last part of this tutorial will make real use of the Test Case and the Read File script we have prepared previously. First thing we have to do is to replace real values in the CelsiusToFahrenheit test case with custom properties we have defined in the Read Files cript as follows:

Now we are using our previously prepared Data File couples for input and expected output properly in our test case.

In order to be able to iterate our modified test case as many times as we have lines defined in our Data File we have to do following ammendments in to our simple iterator Groovy script: Enhanced Groovy script
If you run our improved Groovy script now you will see following result in the log:
Enhanced Groovy script execution
As you can see we have executed our test case 10 times and only seventh test case failed due to fact that we have intentionaly put a wrong expected output value in our Data File.

We are practically done. But to make it all look great we can go back to our TestSuite 1 and disable TempConvert step as follows:
Disable Tempconvert step
Now you can run entire Test Suite 1 and be proud of our FREE soapUI version data driven test execution results:
Final result
Ok now you have got hang of it and you can improve it the way you need.