Groovy脚本在获取22k行时挂起

时间:2019-04-08 15:55:00

标签: groovy soapui

我正在使用Groovy脚本从excel数据源获取SOAP UI请求消息的数据。脚本可以工作到100行以上为止,并且在soap ui中无法响应。

此groovy脚本在SOAP UI中可用于excel中的50条记录,但是我需要使用具有22k行的excel。

这是groovy脚本的完整层次结构:-

  

https://www.belatrixsf.com/blog/trick-for-soapui-free-in-eight-steps/

// IMPORT THE LIBRARIES WE NEED
import com.eviware.soapui.support.XmlHolder
import jxl.*
import jxl.write.*

// DECLARE THE VARIABLES
def myTestCase = context.testCase //myTestCase contains the test case
def counter,next,previous,size //Variables used to handle the loop and to move inside the file
Workbook workbook1 = Workbook.getWorkbook(new File("c:\\dataFile.xls")) //file containing the data
Sheet sheet1 = workbook1.getSheet(0) //save the first sheet in sheet1
size= sheet1.getRows().toInteger() //get the number of rows, each row is a data set
propTestStep = myTestCase.getTestStepByName("Property - Looper") // get the Property TestStep object
propTestStep.setPropertyValue("Total", size.toString())
counter = propTestStep.getPropertyValue("Count").toString() //counter variable contains iteration number
counter = counter.toInteger() //
next = (counter > size-2? 0: counter+1) //set the next value

// OBTAINING THE DATA YOU NEED
Cell u = sheet1.getCell(0,counter) // getCell(column,row) //obtains user
Cell p = sheet1.getCell(1,counter) // obtains password
workbook1.close() //close the file

////////////////////////////////////
usr = u.getContents()
pass = p.getContents()
propTestStep.setPropertyValue("user", usr) //the value is saved in the property
propTestStep.setPropertyValue("pass", pass) //the value is saved in the property
propTestStep.setPropertyValue("Count", next.toString()) //increase Count value
next++ //increase next value
propTestStep.setPropertyValue("Next", next.toString()) //set Next value on the properties step

//Decide if the test has to be run again or not
if (counter == size-1)
{
    propTestStep.setPropertyValue("StopLoop", "T")
    log.info "Setting the stoploop property now..."
}
else if (counter==0)
{
    def runner = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner(testRunner.testCase, null)
    propTestStep.setPropertyValue("StopLoop", "F")
}
else
{
    propTestStep.setPropertyValue("StopLoop", "F")
}

从excel读取22k记录时,预期的输出常规脚本不应挂起。

0 个答案:

没有答案