Most of the times instead of adding comments in an ordinary JUnit
assertion, we add a message to the assertion, to explain why this is assertion is where it is:
Person p1 = new Person("Bob");
Person p2 = new Person("Bob");
assertEquals(p1, p2, "Persons with the same name should be equal.");
Now, when it comes to end point testing in a Spring Boot web environment I end up with this:
// Bad request because body not posted
mockMvc.perform(post("/postregistration")).andExpect(status().isBadRequest());
// Body posted, it should return OK
mockMvc.perform(post("/postregistration").content(toJson(registrationDto))
.andExpect(status().isOk()));
Is there a way to get rid of the comments and add a message to this kind of assertion? So, when the test fails I will see the message.