New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename AssertableMockMvc to MvcTester and review assertions structure #32712
Labels
Milestone
Comments
snicoll
added
status: waiting-for-triage
An issue we've not yet triaged or decided on
in: test
Issues in the test module
labels
Apr 26, 2024
jhoeller
changed the title
Consier renaming and/or restructuring AssertableMvcResult
Consider renaming and/or restructuring AssertableMvcResult
Apr 26, 2024
We've made quite a bit of progress here, focusing on the renaming bit of it. We came to the following proposal:
Irrespective of this issue, we've reviewed of the API and found several shortcuts to be desirable, as well as avoid a double navigation for the body. This proposal is available at https://github.com/snicoll/spring-framework/tree/mvctester-review |
snicoll
added
type: enhancement
A general enhancement
and removed
status: waiting-for-triage
An issue we've not yet triaged or decided on
labels
May 7, 2024
snicoll
changed the title
Consider renaming and/or restructuring AssertableMvcResult
Rename AssertableMockMvc to MvcTester and review assertions structure
May 7, 2024
snicoll
added a commit
that referenced
this issue
May 7, 2024
This commit merges the JSONCompare and JsonPath support in a single assert object. The rationale for the previous situation was that JsonPath is optional but merging the assertions methods do not make it mandatory as the usage if JsonPath is triggered only if it is actually used. See gh-32712
snicoll
added a commit
that referenced
this issue
May 7, 2024
This commit removes ResponseBodyAssert and rather offers first-class access support for the response body at the root level using bodyText(), bodyJson(), and body(). This avoids a double navigation to assert the response body. See gh-32712
snicoll
added a commit
that referenced
this issue
May 7, 2024
This commit renames AssertableMockMvc to MockMvcTester as the former was too mouthful, and we are looking for a naming pattern that can be applied consistently to test utilities that rely on AssertJ. Rather than AssertableMvcResult, we now use MvcTestResult and it no longer extends from MvcResult itself. That avoids having existing code that is migrated to the new API whilst assigning the result to MvcResult and get a bad DevXP as that doesn't bring any of the AssertJ support. See gh-32712
snicoll
added a commit
that referenced
this issue
May 7, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:AssertableMvcResult
expands on the latter by providing the unresolved exception as well, rather than throwing a checked exception asMockMvc
does.This class can then be fed to AssertJ and we can then navigate on various pieces of the result:
There are two things we'd like to explore here:
AssertableMvcResult
is a bit off putting so we should consider renaming itMvcResult
than extendingMvcResult
. This may allow us to navigate to more structured part of the result, such as:paging @philwebb and @simonbasle who helped me brainstorm on this.
The text was updated successfully, but these errors were encountered: