sch*_*omm 1 groovy soapui assertions http-headers
当一个变量有另一个值而不是定义时,我试图让脚本断言失败.我的目标:如果TestStep失败,将TestStep标记为红色.请注意,我正在使用TestStep的脚本断言 - 而不是单独的Groovy-Script TestStep.我的脚本看起来像这样:
httpResponseHeader = messageExchange.responseHeaders
contentType = httpResponseHeader["Content-Type"]
log.info("Content-Type: " + contentType)
if (contentType != "[image/jpeg]"){
log.info("ERROR! Response is not an image.")
//Script Assertion should fail.
//TestStep should be marked red.
} else {
log.info("OK! ResponseType is an image.")
}
Run Code Online (Sandbox Code Playgroud)
有什么办法,如何让脚本断言取决于属性?我试过使用getStatus()方法,但这只适用于testrunner对象.不幸的是,testRunner-object不能在关于这篇文章的脚本断言中使用:http://forum.soapui.org/viewtopic.php? f = 2&t = 2494#p9107
Rao*_*Rao 10
需要断言以便测试失败或根据条件自动传递.
def httpResponseHeader = messageExchange.responseHeaders
def contentType = httpResponseHeader["Content-Type"]
log.info("Content-Type: " + contentType)
assert contentType.get(0) == "image/jpeg","Content Type is not an image"
Run Code Online (Sandbox Code Playgroud)
编辑:早先注意如何抛出错误,假设你有其余的.现在根据输入改变了最后一行代码.
| 归档时间: |
|
| 查看次数: |
6440 次 |
| 最近记录: |