Groovy SoapUI从文件读取请求参数(免费版本)

Groovy SoapUI从文件读取请求参数(免费版本),groovy,soapui,Groovy,Soapui,我有一个包含以下内容的文件 987656 987534 在测试之前,我有一个Groovy脚本作为测试步骤,如下所示: def myTestCase = context.testCase new File("filepath/data1.txt").eachLine { line -> myTestCase.setPropertyValue("inputValue", line) inputValue = context.expand(

我有一个包含以下内容的文件

987656   
987534
在测试之前,我有一个Groovy脚本作为测试步骤,如下所示:

def myTestCase = context.testCase
new File("filepath/data1.txt").eachLine { line ->
  myTestCase.setPropertyValue("inputValue", line)
  inputValue = context.expand( '${#TestCase#inputValue}' )
  log.info inputValue
}

脚本的日志输出为我提供了文件中的两个值:

987656
987534

我有一个Testcase自定义属性设置为“inputValue”,在我的测试中,我将参数称为

 <enr:Id>${#TestCase#inputValue}</enr:Id>

${#测试用例#输入值}
在执行过程中,测试始终针对最后一个值“987534”运行,而不是针对两个输入

我应该怎么做才能对文本文件中的所有值执行测试


感谢

这样循环值的方法,在
eachLine
循环中,调用SOAP步骤,如下所示:

def myTestCase = context.testCase
new File("filepath/data1.txt").eachLine { line ->
    myTestCase.setPropertyValue("inputValue", line)
    inputValue = context.expand( "${#TestCase#inputValue}" )
    log.info inputValue

    //define the step
    def soapTestStep = testRunner.testCase.getTestStepByName("YourSOAPRequestName").name
    
    //call the step
    testRunner.runTestStepByName(soapTestStep)

    //if you want to do something with the response XML
    def responseSOAP = context.expand("${YourSOAPRequestName#Response}")

    //if you want to check a value in the response XML
    def responseSection = responseSOAP =~ /someNode>(.*)<\/someNode/   
    def responseValue = responseSection[0][1]
    log.info "response: ${responseValue}"
}
def myTestCase=context.testCase
新文件(“filepath/data1.txt”).eachLine{line->
myTestCase.setPropertyValue(“inputValue”,第行)
inputValue=context.expand(“${TestCase}inputValue}”)
log.info输入值
//定义步骤
def soapTestStep=testRunner.testCase.getTestStepByName(“您的SOAPRequestName”).name
//叫台阶
runTestStepByName(soapTestStep)
//如果您想对响应XML执行某些操作
def responseSOAP=context.expand(“${YourSOAPRequestName#Response}”)
//如果要检查响应XML中的值

def responseSection=responseSOAP=~/someNode>(*)这是预期的。因为在脚本中,它读取所有内容,最后一行值作为自定义属性。因此,您可以看到结果。您必须为每个内容运行测试。谢谢@ou_ryperd。当我尝试上述操作时,对数据文件987656、987534中的两个值都执行了测试。但是,测试运行了3个步骤,重复了last值两次。