playframework / playframework/play1
In functional tests, unhandled exception in controller method leads to 200 response instead of 500
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.6k
- Forks
- 671
- Avg merge
- 12d 15h
- Merged PRs (30d)
- 1
Description
When a controller method throws an unhandled exception, under normal circumstances this leads to 500 error page. However if I make request to the same method from the functional test, I get a 200 OK response.
This really breaks my functional testing, as my tests can not catch a bug which can be easily seen if opening the page manually in a browser.
To get my error I need either to use selenium test (which is slow, but it gets same result as a browser) or to wrap controller method into:
try { ... } catch (Exception ex) { error() }
In case of explicit error() call the functional test gets correct 500 return code.
I created a sample webapp, where Application.index() method throws a runtime exception and a functional test checks that its return status is 500:
https://drive.google.com/file/d/0B72ZMlJTpA1VLWxpd0lMWk5JSHM/view?usp=sharing
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
Reproduce the issue with the linked sample webapp, where Application.index() throws a runtime exception during a functional test. Compare the functional-test response with the browser behavior and the explicit error() case. Done when an unhandled controller exception produces a 500 status in the functional test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100