文件只显示一种形式的请求和响应

时间:2017-05-09 11:43:24

标签: groovy soapui

我正在生成一个文件,它应该从不同的SOAP请求步骤输出2个不同的请求和2个不同的响应:

TestRegion
TestRules

但是我注意到该文件只是生成TestRegion个请求并且每次响应2次。对于每个请求,它会显示TestRegion个请求,并且对于每个响应,它都会显示TestRegion个响应。为什么会这样做?如何才能获得正确的请求和响应?它会像TESTREGION REQUEST:一样显示硬编码字符串,然后在TEST REGION RESPONSE上显示,但请求和响应不正确。

def testRegionRequest = context.expand( '${${TestRegion}#Request}'  )
def testRegionResponse = context.expand( '${${TestRegion}#Response}'  )
def testRulesRequest = context.expand( '${${TestRules}#Request}'  )
def testRulesResponse = context.expand( '${${TestRules}#Response}'  )


def fileName = "XXX.txt"
def logFile = new File(fileName)

//Draws a line
def drawLine(def letter = '=', def count = 70) { letter.multiply(count)}

def testResult = new StringBuffer() 
testResult.append drawLine('-', 60) + "\n\n" 
testResult.append "\n\nTEST REGION REQUEST:\n\n" 
testResult.append(testRegionRequest.toString())
testResult.append "\n\n" + drawLine('-', 60) + "\n\n" 
testResult.append "\n\nTEST REGION RESPONSE:\n\n" 

testResult.append(testRegionResponse.toString())
testResult.append "\n\n" + drawLine('-', 60) + "\n\n" 
testResult.append "\n\nTEST RULES REQUEST:\n\n"
testResult.append(testRulesRequest.toString())
testResult.append "\n\n" + drawLine('-', 60) + "\n\n" 
testResult.append "\n\nTEST RULES RESPONSE:\n\n"
testResult.append(testRulesResponse.toString())

// Now create and record the result file
logFile.write(testResult.toString()) 

1 个答案:

答案 0 :(得分:1)

您似乎在context.expand

中使用的值不正确

更改自:

${${SearchRegion}#Request}

要:

${SearchRegion#Request}

同样适用于其他属性。

相关问题