Forum Discussion

IsmailBERRADA's avatar
IsmailBERRADA
New Contributor
12 years ago

SOAPUI 4.5

Hi every on
Here is my goal:
I have already a test case
But I want to add a new feature.
1) I want to read datas from a CSV file. The
2) loop over each lines of the CSV file
3) Set my tests case properties from datas
4) execute my test case

I start to write the groovy script but when I run my test case soapui freeze


log.info("Start script")
def tc = testRunner.testCase
def file = new File('/tmp','test.csv')
def lines = file.readLines()
def i = 0

for(i = 1; i < lines.size; i++) {
def datas = lines[i].split(";")

def j = 0
for(j = 0; j < datas.length; j++) {
tc.setPropertyValue( "Prop1",datas[0] )
tc.setPropertyValue( "Prop2",datas[1] )
tc.setPropertyValue( "Prop2",datas[2] )
tc.setPropertyValue( "Prop4",datas[3] )
tc.setPropertyValue( "Prop5",datas[4] )
tc.setPropertyValue( "Prop6",datas[5] )


}

}
log.info("End of script")


I added logs and I saw that the csv file has been read and I can see datas extracted from the file
my script works well except if I add the following line:

tc.run(new com.eviware.soapui.support.types.StringToObjectMap(), false)


My script then becomes

def tc = testRunner.testCase
def file = new File('/tmp','test.csv')
def lines = file.readLines()
def i = 0

for(i = 1; i < lines.size; i++) {
def datas = lines[i].split(";")

def j = 0
for(j = 0; j < datas.length; j++) {
tc.setPropertyValue( "Prop1",datas[0] )
tc.setPropertyValue( "Prop2",datas[1] )
tc.setPropertyValue( "Prop2",datas[2] )
tc.setPropertyValue( "Prop4",datas[3] )
tc.setPropertyValue( "Prop5",datas[4] )
tc.setPropertyValue( "Prop6",datas[5] )
}
tc.run(new com.eviware.soapui.support.types.StringToObjectMap(), false)
}


and then soapui freeze

Did anyone had this problem ?
best regards
No RepliesBe the first to reply