如何捕获带有状态的 soapui 断言列表
How can I capture soapui assertions list with status
如果您 运行 一个 testStep 并查看断言。 SoapUI returns 断言 Green/Red 以及添加“- VALID”或“- FAILED”
问题:有没有办法捕获完整的字符串?
姓名+身份
即
SOAP 响应 - 有效
XPath 匹配 - 有效
包含 - 有效
不包含 - 失败
目前我正在提取 assertionsList - 但我希望额外的状态部分与它一起使用。
谢谢,
罗布
要打印 testCase
中所有 testSteps
的所有断言,您可以在 testCase
的 tearDown script
中使用以下 groovy 脚本,它使用 getAssertionList()
which returns a TestAssertion
list, and then iterates over it using label
and status
属性:
testRunner.testCase.testSteps.each{ name,props ->
log.info "Test step name: $name"
// check that the testStep class support assertions
// (for example groovy testStep doesn't)
if(props.metaClass.respondsTo(props, "getAssertionList")){
// get assertionList
props.getAssertionList().each{
log.info "$it.label - $it.status"
}
}
}
注意: 并非所有类型的 testStep 都有断言(例如 Groovy 脚本 testStep 没有)所以在使用前有必要检查它 getAssertionList()
)
如果您想从一个特定的 testStep
获取所有断言,您可以在 groovy 脚本中使用相同的方法:
// get the testStep
def testStep = testRunner.testCase.getTestStepByName('Test Request')
// check that the testStep specific class support assertions
// (for example groovy testStep doesn't)
if(testStep.metaClass.respondsTo(testStep, "getAssertionList")){
// print assertion names an its status
testStep.getAssertionList().each{
log.info "$it.label - $it.status"
}
}
希望对您有所帮助,
如果您 运行 一个 testStep 并查看断言。 SoapUI returns 断言 Green/Red 以及添加“- VALID”或“- FAILED”
问题:有没有办法捕获完整的字符串? 姓名+身份
即 SOAP 响应 - 有效 XPath 匹配 - 有效 包含 - 有效 不包含 - 失败
目前我正在提取 assertionsList - 但我希望额外的状态部分与它一起使用。
谢谢, 罗布
要打印 testCase
中所有 testSteps
的所有断言,您可以在 testCase
的 tearDown script
中使用以下 groovy 脚本,它使用 getAssertionList()
which returns a TestAssertion
list, and then iterates over it using label
and status
属性:
testRunner.testCase.testSteps.each{ name,props ->
log.info "Test step name: $name"
// check that the testStep class support assertions
// (for example groovy testStep doesn't)
if(props.metaClass.respondsTo(props, "getAssertionList")){
// get assertionList
props.getAssertionList().each{
log.info "$it.label - $it.status"
}
}
}
注意: 并非所有类型的 testStep 都有断言(例如 Groovy 脚本 testStep 没有)所以在使用前有必要检查它 getAssertionList()
)
如果您想从一个特定的 testStep
获取所有断言,您可以在 groovy 脚本中使用相同的方法:
// get the testStep
def testStep = testRunner.testCase.getTestStepByName('Test Request')
// check that the testStep specific class support assertions
// (for example groovy testStep doesn't)
if(testStep.metaClass.respondsTo(testStep, "getAssertionList")){
// print assertion names an its status
testStep.getAssertionList().each{
log.info "$it.label - $it.status"
}
}
希望对您有所帮助,