响应不匹配(虽然匹配)

时间:2021-04-12 12:44:01

标签: java rest

有人可以协助断言以下内容:

String Givencoordinates = "[[-45.85112, 18.17335], [-45.85164, 18.173283], [-45.85283, 18.17247]]"

想用以下代码断言上面的字符串:

given()
    .get(apiUrl)
    .then()
    .assertThat()
    .body(“angle", equalTo(Collections.singletonList(120)))
    .body("coordinates", equalTo((Collections.singletonList(Givencoordinates)));

第一步(身体 - 角度)通过,但一秒钟,出现以下错误:

JSON path coordinates doesn't match.
Expected: <[[-45.85112, 18.17335], [-45.85164, 18.173283], [-45.85283, 18.17247]]>
Actual: [[-45.85112, 18.17335], [-45.85164, 18.173283], [-45.85283, 18.17247]]

在断言中尝试使用 (Collections.singletonList(Givencoordinates)(Arrays.asList(Givencoordinates),但得到相同的错误。

此错误的解决方案是什么?谢谢

1 个答案:

答案 0 :(得分:1)

Junit 输出正在对您的数据调用 DirectMessageListenerContainer

您应该尝试将预期值定义为实际列表,而不是将单个字符串放入一个元素的列表中

相关问题