我有以下功能:
public class NorthboundApiLogicTest {
@Test
public void testIfParametersValuesAreCorrect() {
String body = "{\"exception\":\"world\",\"error\":\"Not Found\",\"message\":\"hello\""
+ ",\"timestamp\":\"2020-01-07T12:26:48.334386Z\",\"status\":\"404\"}";
try {
JSONAssert.assertEquals("{message:hello, exception:world, status:403, error:Not Found}",
body, false);
} catch (Exception e) {
System.err.println(e);
}
System.out.println(body);
}
}
我用 Maven 运行这个测试,奇怪的是它成功通过了。
但是,它不应该,因为我断言status=403
但值是404
. 我究竟做错了什么?