首页 > 解决方案 > 是否有机会在 Rest Assured 方法中添加断言消息?

问题描述

有没有机会使用 Rest Assured 库将断言消息添加到我的方法中?例如,我想在这个链方法中写一个断言消息,而不使用 System.out.println()。

given().spec(requestSpecBuilder).when().get(commentsEndPoint).then().
            spec(responseSpecification).assertThat().contentType(ContentType.JSON.withCharset("UTF-8"))

标签: javarest-assuredhamcrest

解决方案


不,Rest-Assured 没有这样的方法。

要添加断言消息,您可以直接使用 Hamcrest。

Response res = given().when().get("your_url");
assertThat("Check status code", res.statusCode(), Matchers.is(200));

推荐阅读