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
//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(",")

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

def groovyUtils = new
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”)

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(",")