测试人社区

求助httprunner,同一接口不同响应结果走不同的断言该怎么写呢?

{"code":189002,"msg":"验证码错误或已过期","data":null,"ok":false}
{"code":0,"msg":null,"phone":"18802681032","member":false},"ok":true}

如上所示,想实现
code==189002时只校验status_code、code
code==0时校验status_code、code和phone

.validate()
.assert_equal("status_code", "${status_code}")
.assert_equal("body.code", "${responsecode}")
.assert_equal("body.data.phone","${phone}")

在httprunner中不知道能不能这样实现,求大神指点