-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Closed
Labels
in: testIssues in the test moduleIssues in the test moduletype: enhancementA general enhancementA general enhancement
Milestone
Description
When we perform a request with MockMvc, we get a MvcResult
that contains all the elements we need to assert that the processing of the request went well, such as:
- The request and the response
- What handler handled the request, and the ModelAndView if any
- A resolved exception if the processing failed and an exception handled handled it
AssertableMvcResult
expands on the latter by providing the unresolved exception as well, rather than throwing a checked exception as MockMvc
does.
This class can then be fed to AssertJ and we can then navigate on various pieces of the result:
assertThat(result).hasStatusOk()
assertThat(result).body()...
assertThat(result).headers()...
assertThat(result).cookies()...
assertThat(result).model()...
assertThat(result).handler()...
There are two things we'd like to explore here:
- We want users to assign the result of perform so that they can run multiple asserts against the result. The name
AssertableMvcResult
is a bit off putting so we should consider renaming it - If we did then we should investigate the possiblity of exposing a
MvcResult
than extendingMvcResult
. This may allow us to navigate to more structured part of the result, such as:
assertThat(result.body())...
assertThat(result.headers())...
paging @philwebb and @simonbasle who helped me brainstorm on this.
philwebb
Metadata
Metadata
Assignees
Labels
in: testIssues in the test moduleIssues in the test moduletype: enhancementA general enhancementA general enhancement