play1 icon indicating copy to clipboard operation
play1 copied to clipboard

In functional tests, unhandled exception in controller method leads to 200 response instead of 500

Open smirnovegorv opened this issue 9 years ago • 1 comments

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

smirnovegorv avatar Sep 15 '16 21:09 smirnovegorv

Fixed in https://github.com/playframework/play1/pull/1246 needs reviewing and approving.

Fraserhardy avatar Jul 25 '18 22:07 Fraserhardy