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
Allow grouping assertions in MvcResultAssert
#32642
Comments
The way to do this with AssertJ is via |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Boilerplate code that's not needed when using the established I don't want to repeat the discussion we already had on #32643. I'd just, for the record, would like to leave that being able to define expectations on any aspect of the response in any order has been idiomatic with I've found the discoverability of domain-specific assertions (the methods specific to responses and response aspects) to be quite hidden between all the generic assertion methods ( Just to make sure I don't appear obnoxious about this: I think we're dealing with two separate idiomacies here. One being the established MockMvc programming model that allowed users to flexibly and fluently trigger assertions on different aspects. The other being the way that AssertJ assertions being designed usually. There are two reasons that I think we should favor the former over the latter:
|
I think we're coming from two different camps and it's a question of whether we could please both camps by offering both approaches but there's more code to maintain and that'd force users to figure out which they should use. For me, if I'm choosing to use
IMO, that's the established approach with AssertJ and it feels natural to me as an experienced user of AssertJ.
I don't think this is the target audience. I expect Repeating myself, assigning the result with multiple On a final note, Spring Security is moving away from With all that said, |
MvcResultAssert
MvcResultAssert
So we've spent quite a bit of time in #32712 and that led to a bit of more first-level type on the root assert but nothing that would change significantly what we have. We'll continue iterating but I want to emphasis on what what said previously and our wish to follow AssertJ conventions. |
Standard
MockMvc
allows setting up expectations targeting different aspects of the response through its….andExpect(…)
method. OnMvcResultAssert
, once you move into a particular assert, for example….contentType()
, there's no way to get back toMvcResultAssert
, to define constraints on another aspect of the response.Do you think there could be an
….and()
method that would navigate back toMvcResultAssert
and allow me to write something like this?The current workaround is assigning
MvcResultAssert
to a variable and calling those methods on it, which adds a bit of ceremony.The text was updated successfully, but these errors were encountered: