Provide methods to unambiguously send form data with MockMvc #32757
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
A recent Spring REST Docs issue has reminded me of the ambiguity of using the
param
method when building a mock request. You cannot tell if the parameter was intended to come from the request's query string or its body which causes REST Docs some problems as it has to guess. Beyond REST Docs, even when setting the content type to indicate that parameters (probably) come from the body, a test like this will fail:I discussed this many years ago with @rstoyanchev where he suggested that some new methods specifically for adding form parameters could be introduced. I would welcome such an addition, ideally alongside the deprecation of the
param
method, as it would allow test code to unambiguously describe the request. This would benefit REST Docs and would also, I believe, allow MockMvc to automatically populate the request's body from the form parameters which, as shown by the test above, it does not do today.The text was updated successfully, but these errors were encountered: