您可以/如何从SoapUI断言中运行groovy脚本,而无需将脚本复制/粘贴到需要执行相同脚本的所有测试步骤中?是否可以在断言之外编写脚本并像调用方法那样运行脚本?这样您就可以在多个测试步骤中重用断言脚本。
到目前为止,我尝试从断言中调用groovy测试步骤,但是run()
方法需要一个断言中不可用的testRunner
变量。我还尝试将groovy脚本编写为调用另一个groovy测试步骤脚本的后续测试步骤(而不是断言),但我无法将响应从一个测试步骤转移到下一个测试步骤(老实说,我不希望创建真正只是断言的测试步骤)。
注意:这不是How to create variables in soapui test case that can be accessed across all test steps - groovy test step & script assertion test step?的重复,因为这个问题涉及到存储属性,而不是重用脚本。
发布于 2018-11-08 18:42:24
我终于找到了第二种方法:添加另一个groovy脚本作为后续的测试步骤,该步骤具有断言并传递响应。剧本是:
context.response = context.expand('${MyTestStep#Response}') // store response to context variable
Object result = testRunner.testCase.testSuite.testCases['Validate Response'].testSteps['Validate Response'].run(testRunner, context)
if(result.getError() != null) {
log.error("error", result.getError())
assert false
}
assert true
MyTestStep
是groovy脚本之前的测试步骤。Validate Response
是groovy脚本的测试用例名称,也称为Validate Response
,并通过run
方法执行。
https://stackoverflow.com/questions/53214014
复制相似问题