Skip to main content

Data driven testing in SoapUI from csv file

I will show you how to execute SoapUI test for a set of values. For this I have put all data in csv file. I write groovy scripts for reading data from csv and executing the test steps.
Below is the groovy script for reading data from “TestData.csv” file where I put all user credentials.

def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)

def csvFilePath = "E:\\TestData.csv"
context.fileReader = new BufferedReader(new FileReader(csvFilePath))

rowsData = context.fileReader.readLines()
int rowsize = rowsData.size()

for(int i =0;  I < rowsize;  i++)
{

    rowdata = rowsData[i]
    String[] data = rowdata.split(",")
    log.info data[1]
   
    groovyUtils.setPropertyValue("Login", "UserName", data[0])
    groovyUtils.setPropertyValue("Login", "Pass", data[1])
    testRunner.runTestStepByName( "Login")  
}

In above code I read data from “TestData.csv” file and pass user name and password into “UserName “ and “Pass” of Login steps parameters.
“Login”  test step executed by using test runner for every data.

Comments