当我使用testResponse.code == 401时,我可以从控制台日志中看到“预期”和“实际”。但是当我使用checkResponseCode(testResponse,401)时,我得到以下内容:
Condition not satisfied:
checkResponseCode(testResponse, 401)
| |
false testpackage.project1.hs.unittestspack.utils.TestClass@17d88132
如何修复checkResponseCode()方法以使其产生预期和实际?这是checkResponseCode()的实现:
static def checkResponseCode(resp, code) {
resp.code == code
}
这是我想要实现的日志:
Condition not satisfied:
testResponse.code == 401
| | |
| 500 false
testpackage.project1.hs.unittestspack.utils.TestClass@5b367418
Expected :401
Actual :500
<Click to see difference>
答案 0 :(得分:4)
您可以在助手方法中断言条件:
static void checkResponseCode( resp, code ) {
assert resp.code == code
}