Forum Discussion

haiintel's avatar
haiintel
New Contributor
8 years ago

The request run 2 times

Hi All,

 

I'm new to SoapUI, and I'm trying to create data driven test with free SoapUI tool with this service http://www.webservicex.net/country.asmx following this guide http://testautomationnoob.blogspot.com/2012/10/soapui-data-looping-with-groovy-script.html

 

However, my request always run 2 times, I don;t know why.

 

Please help me, here is test case Setup script:

 

//Create a new filereader object, using the context variable so it can be used between test components
context.fileReader = new BufferedReader(new FileReader("D:/data.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(",")
log.info propData[0]
testCase.setPropertyValue("countryCode",propData[0])
testCase.setPropertyValue("countryName",propData[1])

 

The Read Data script:

/*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(",")
curTC = testRunner.testCase
log.info propData[0]
log.info propData[1]
curTC.setPropertyValue("countryCode",propData[0])
curTC.setPropertyValue("countryName",propData[1])
testRunner.gotoStep(0)
}

 

This is the script assertion:

import com.eviware.soapui.support.XmlHolder

responsexmlholder = new XmlHolder(messageExchange.getResponseContentAsXml())

Cdataxml = responsexmlholder.getNodeValue("//*:GetCountryByCountryCodeResult")
Cdataxmlholder = new XmlHolder(Cdataxml)
country = Cdataxmlholder.getNodeValue("//name")

assert country == context.expand('${#TestCase#countryName}')
log.info "right dddddd ${country}"

 

 

Many thanks for your time,