【发布时间】:2018-03-25 17:00:19
【问题描述】:
我收到以下异常消息,但实际和预期是相同的。给定的失败原因似乎不正确。
@Test
public static void Verify()
{
given().
get("http://services.groupkt.com/country/get/all").
then().body("RestResponse.messages", equalTo("[Total [249] records
found.]"));}
FAILED: Verify
java.lang.AssertionError: 1 expectation failed.
JSON path RestResponse.messages doesn't match.
Expected: [Total [249] records found.]
Actual: [Total [249] records found.]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) and much more....
【问题讨论】:
-
这可能意味着尾随空格或某些字符,使您在视觉上看起来相同。请检查没有额外的空格或其他东西
-
实际上输出只证明了预期和实际产生了相同的 toString() 表示,它们不一定是相同的类型。顺便问一下,响应正文属于哪种内容类型?
-
响应为 JSON 格式。
标签: selenium rest-assured hamcrest rest-assured-jsonpath