我有这个"content“响应,我需要从中断言一些值。
WebTestClient.BodyContentSpec content = response.expectStatus().isOk()
.expectBody()
.jsonPath("$.path1").isEqualTo(value1);如果我想用预定义的值断言一些JSON路径,那么一切都很好。
但是,当我想检查一个JSON路径是否等于另一个JSON路径时,就会遇到棘手的问题。
JsonPathAssertions jsonPath2 = bodyContentSpec.jsonPath("$.path2");
JsonPathAssertions jsonPath3 = bodyContentSpec.jsonPath("$.path3");所以我的问题是,我如何使用org.hamcrest.Matchers.greaterThanOrEqualTo针对jsonPath3断言jsonPath2的内容
发布于 2019-04-16 18:04:10
我认为你可以使用value(Consumer)方法:
对于简单的操作:
jsonPath2.value(v->jsonPath3.isEqualTo(v));对于使用特殊的匹配器:
jsonPath2.value(v->jsonPath3.value(Matchers.greaterThanOrEqualTo(v)));https://stackoverflow.com/questions/55702745
复制相似问题