java - 是否有机会在 Rest Assured 方法中添加断言消息?
问题描述
有没有机会使用 Rest Assured 库将断言消息添加到我的方法中?例如,我想在这个链方法中写一个断言消息,而不使用 System.out.println()。
given().spec(requestSpecBuilder).when().get(commentsEndPoint).then().
spec(responseSpecification).assertThat().contentType(ContentType.JSON.withCharset("UTF-8"))
解决方案
不,Rest-Assured 没有这样的方法。
要添加断言消息,您可以直接使用 Hamcrest。
Response res = given().when().get("your_url");
assertThat("Check status code", res.statusCode(), Matchers.is(200));
推荐阅读
- c# - 上传excel文件并更新相同的记录asp.net
- reactjs - 如何在 Create React App 中删除死代码
- javascript - 在 JavaScript 中洗牌数组的更有效方法是什么?
- android - 将位图传递给 Kotlin 中的另一个 Activity
- git - 个人 git repo & .gitignore 文件
- swift - Swift Core Data 获取数据 1 列
- c# - 从视图模型更改 Xamarin 表单应用程序页面
- otrs - 在 OTRS 工单视图中添加列
- laravel - 使用 babel 和 laravel-mix 将 ES6 转换为 ES2015
- android - 如何在我的应用程序中访问工具栏小部件上的文本?