1
votes

In a test example

@Test
public void aSampleTest() {
    this.mockMvc
      .perform(get("/ultimateQuestion"))
      .andExpect(jsonPath("$.meaningOfLife", is("42"));
}

... is it possible to add a (failing) test description, so that a failing test has a human-readable message rather than just

Expected: is "42"
   but was 24

I mean, similar to

assertTrue(boolean condition, String message)

as opposed to

assertTrue(boolean condition)
1

1 Answers

0
votes

No, there is currently no way to customize the failure "reason".

It is hard coded to "JSON path \"" + this.expression + "\"" in org.springframework.test.util.JsonPathExpectationsHelper.assertValue(String, Matcher<T>), where this.expression is the JsonPath expression you supply (e.g., "$.meaningOfLife" in your example).