如何在没有字符串的情况下验证身体反应?

时间:2019-05-07 20:11:58

标签: java rest-assured rest-assured-jsonpath

我正在放心开发API自动化测试。我的API响应类似于:

{
    "is_active": true,
    "token": "s4vj75pj6********"
}

当我发送无效计数时,就像:

{
    "is_active": false,
    "token": ""
}

所以我想验证响应是否为“ true”,所以我开发了以下代码:

public void responseLoginFacebookBody () {
            Assert.assertTrue(ResponseHolder.getResponseBody().contains("is_active"));
            String responseStatus = ResponseHolder.getResponseJson().get("is_active");
            Assert.assertTrue(responseStatus.equalsIgnoreCase("true"));
        }

但是我收到以下消息:

  

java.lang.ClassCastException:无法将java.lang.Boolean强制转换为java.lang.String

我如何验证它?

1 个答案:

答案 0 :(得分:3)

responseStatus更改为boolean。它不是您的API响应中的字符串

相关问题