Date Driven Tesitng – SoapUI Pro

I’m putting this up now in a pinch for a Linked-In question (Hello Ravi)
Pro Version:
Pro Version has internal test-steps that read from an excel file or other source and Loops the process until the data is exhausted.

1.  DataSource Test Step

DataSource Test Step in SoapUI Pro
DataSource Test Step in SoapUI Pro

Important that you use XLS only – not the newer XLSX which is not supported in 4.5.x

Here we have in regards to settings for Excel:

  • Left Side – Properties (are named after the headings in your Excel File)
  • Right Side:  FILE = Path to your XLS   WORKSHEET = Sheet Name (tab)    START AT CELL = Where does the data start?  If you have headers you will start at A2
  • Finally “Ignore Empty:” should be checked otherwise it can keep looping.
DataSource Settings for Excel in SoapUI Pro
DataSource Settings for Excel in SoapUI Pro
  • Click on the Green “Run” and you’ll see the info pull from the excel file.  (Use ‘0’ at the prompt to pull all values in the worksheet.

NOTE:  If you want to capture any return values you need (Property Transfer step which will populate a DataSink Step which will write to an output file.

2.  DataSource Loop Test Step

DataSource Loop Test Step in SoapUI Pro
DataSource Loop Test Step in SoapUI Pro

Free Version:

You don’t have the options for these Test Steps – so be careful in developing an XML and soon you’re out of a license and can’t use it…

So with that said you can read from a file using Groovy Script.

1. The following code I have in a TestCase Setup Script which will INSERT the value into a Property TestStep for use.


f = new File("bulk_output_vonage.txt")//---Saves in //SmartBear\soapUI-4.5.x\bin
f.append("bulk_output_vonage"+"\r\n+-custid--+-phoneNum--+-username-+")
//Create a new filereader object, using the context variable so it can be used between test components
context.fileReader = new BufferedReader(new FileReader("C:\\VonageCustomer_BulkUpload.txt"))
//Read in the first line of the data file
firstLine = context.fileReader.readLine()
//Split the first line into a string array and assign the array elements to various test case properties
String[] propData = firstLine.split(",")
testCase.testSteps["Read_CSV_Property"].setPropertyValue("firstName",propData[0])
testCase.testSteps["Read_CSV_Property"].setPropertyValue("lastName",propData[1])
testCase.testSteps["Read_CSV_Property"].setPropertyValue("username",propData[2])
testCase.testSteps["Read_CSV_Property"].setPropertyValue("emailAddress",propData[3])

2. Then I send values pulled form responses to an output file using a Groovy Test Step:


def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def acctNum = context.expand( '${Read_CSV_Property#accountNumber}' )
def did = context.expand( '${Read_CSV_Property#phoneNumber}' )
def userName = context.expand( '${Read_CSV_Property#userName}' )

f = new File(“bulk_output_vonage.txt”)
f.append(“\r\n”+acctNum+”,”+did+”,”+userName+”\r\n”)

3. Read the Next Line in the file & Loop the Test Case

/*Read in the next line of the file
We can use the same fileReader created in the Setup script because it
was assigned to the context variable.*/
nextLine = context.fileReader.readLine()
/*If the end of the file hasn't been reached (nextLine does NOT equal null)
split the line and assign new property values, rename test request steps,
and go back to the first test request step*/
if(nextLine != null){
String[] propData = nextLine.split(",")

testRunner.testCase.testSteps[“Read_CSV_Property”].setPropertyValue(“firstName”,propData[0])
testRunner.testCase.testSteps[“Read_CSV_Property”].setPropertyValue(“lastName”,propData[1])
testRunner.testCase.testSteps[“Read_CSV_Property”].setPropertyValue(“username”,propData[2])
testRunner.testCase.testSteps[“Read_CSV_Property”].setPropertyValue(“emailAddress”,propData[3])
testRunner.testCase.testSteps[“Read_CSV_Property”].setPropertyValue(“addressLine1”,propData[4])
testRunner.testCase.testSteps[“Read_CSV_Property”].setPropertyValue(“st.Number”,propData[5])
testRunner.testCase.testSteps[“Read_CSV_Property”].setPropertyValue(“st.Name”,propData[6])
testRunner.testCase.testSteps[“Read_CSV_Property”].setPropertyValue(“st.Type”,propData[7])
testRunner.testCase.testSteps[“Read_CSV_Property”].setPropertyValue(“addressLine2”,propData[8])
testRunner.testCase.testSteps[“Read_CSV_Property”].setPropertyValue(“city”,propData[9])
testRunner.testCase.testSteps[“Read_CSV_Property”].setPropertyValue(“state”,propData[10])
testRunner.testCase.testSteps[“Read_CSV_Property”].setPropertyValue(“zipCode”,propData[11])
testRunner.testCase.testSteps[“Read_CSV_Property”].setPropertyValue(“country”,propData[12])

testRunner.gotoStep(0)
}