我目前有一个包含76个肥皂测试步骤的测试套件,其中所有测试套件都已运行。但是在日志中,我按预期获得测试步骤名称,但没有响应。
groovy脚本和测试步骤都在同一个测试套件中但不同的测试用例。它具有以下结构:
的TestSuite
Groovy脚本:
def testCases = context.testCase.testSuite.getTestCaseList()
testCases.each
{
for(testSteps in it.testStepList)
{
log.info "~~~Test Step:" + testSteps.name
def requestname = testSteps.name
log.info context.expand('${'+requestname+'#Response}')
}
}
日志:
Tue Mar 21 11:50:04 GMT 2017:INFO:~~~Test Step:TestStep_0001
Tue Mar 21 11:50:04 GMT 2017:INFO:
Tue Mar 21 11:50:04 GMT 2017:INFO:~~~Test Step:TestStep_0002
Tue Mar 21 11:50:04 GMT 2017:INFO:
Tue Mar 21 11:50:04 GMT 2017:INFO:~~~Test Step:TestStep_0003
Tue Mar 21 11:50:04 GMT 2017:INFO:
为什么我没有获得每个测试步骤的响应中的数据?
答案 0 :(得分:2)
以下是Groovy Script
,它可以满足您的需求:
关键是使用step.getPropertyValue('Response')
import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep
//Repeat thru test cases
context.testCase.testSuite.testCaseList.each { tc ->
tc.testStepList.each { step ->
log.info "~~~Test Step:" + step.name
if (step instanceof WsdlTestRequestStep) {
log.info step.getPropertyValue('Response')
} else {
log.info 'Ignoring step as it is not SOAP request type step'
}
}
}