Dancer::Test and negative testing, error reporting
Dear List, I casually use `die` inside my handlers to report errors. This works ok when i use the application with the browser. The `die`s are translated to HTTP 500, the error is reported to the user. Now my problem: I want to test corner-cases in my Dancer::Test cases. But in the test-cases, my `die`s are not translated to HTTP 500, instead the test dies "Dubiously". Is there a way to get Dancer::Test to behave like Dancer w/o Test? I really don't want to `eval` all my tests - set aside that this would also not allow me to test for HTTP 500. Alternatively, how should error reporting happen without `die`? I miss my structured exception handling... Any help greatly appreciated, -- Rudolf Muehlbauer <rudolf.muehlbauer@gmail.com>
On Sat, Mar 5, 2011 at 7:44 PM, Rudolf Muehlbauer <rudolf.muehlbauer@gmail.com> wrote:
Dear List,
I casually use `die` inside my handlers to report errors. This works ok when i use the application with the browser.
The `die`s are translated to HTTP 500, the error is reported to the user.
Now my problem: I want to test corner-cases in my Dancer::Test cases. But in the test-cases, my `die`s are not translated to HTTP 500, instead the test dies "Dubiously".
Is there a way to get Dancer::Test to behave like Dancer w/o Test? I really don't want to `eval` all my tests - set aside that this would also not allow me to test for HTTP 500.
Alternatively, how should error reporting happen without `die`? I miss my structured exception handling...
Inside of your routes, you can return a 500 error response: get '/test500' => sub { return error 'oops' }; -Naveed
Any help greatly appreciated,
-- Rudolf Muehlbauer <rudolf.muehlbauer@gmail.com>
_______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
participants (2)
-
Naveed Massjouni -
Rudolf Muehlbauer