spring-projects / spring-projects/spring-framework
Support HTTP status error pages on MockMvc [SPR-13966]
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 60.2k
- Forks
- 38.8k
- Avg merge
- 5d 2h
- Merged PRs (30d)
- 27
Description
Christopher Smith opened SPR-13966 and commented
MockMvc does not run an actual servlet container but implements part of the stack for testing purposes. Currently, MockMvc does not support content in error responses; for example, a 403 or 404 status will result in an empty body.
With the new HtmlUnit driver support, it's very simple to write most functional tests in something like Spock+Geb, but tests that expect an error (e.g., "Bob can't view Alice's document") require dropping back into the MockMvc DSL because the driver only exposes the view content and not the status code.
I would like to be able to configure the MockMvc to serve HTML pages as error responses, similar to Boot's ConfigurableEmbeddedServletContainer#addErrorPages(ErrorPage[]) so that I can use ordinary Selenium methods of identifying when I've encountered an error.
Affects: 4.2.4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading MockMvc's error-response handling and the HtmlUnit driver support described in the issue, then compare the requested behavior with Boot's ConfigurableEmbeddedServletContainer#addErrorPages(ErrorPage[]). Determine how configurable HTML error pages should be served for statuses such as 403 and 404, and verify that functional tests can observe the resulting error content.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100