Skip to content

Instantly share code, notes, and snippets.

@RhysC
Created December 16, 2014 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RhysC/ed053eee9517f3509e96 to your computer and use it in GitHub Desktop.
Save RhysC/ed053eee9517f3509e96 to your computer and use it in GitHub Desktop.
My hopes and dreams for error handling in Asp.net - defined in cukes
Feature: Error handling in asp.net
Errors occur in web apps and we need to be able to handle the exceptions (e.g. log them) and show customers appropriate messages in a meaning full and consistent manner.
These test assume Accept:text/html or equivalent
#RHYSC -I don't mind how the error information is surfaced but it should be accessible in a common and clean manner
#these specs can be extrapolated out to the other error codes too
Scenario: 404 on static files
Given a static file ~/test.html does not exist
When we navigating to ~/test.html
Then the on error event should be raised by XYZ with path information and 404 http status code
And the 404 error page should be shown with a response code of 404
And the URL path should be still be /Test/Fail
Scenario: 404 on bad routes
Given a route /IDont/Exist is not defined
When we navigating to ~/IDont/Exist
Then the on error event should be raised by XYZ with path information and 404 http status code
And the 404 error page should be shown with a response code of 404
And the URL path should be still be /Test/Fail
Scenario: 404 on bad actions
Given a route /test/{action} is not defined
And the action Fail does not exist on TestController
When we navigating to ~/Test/Fail
Then the on error event should be raised by XYZ with path information and 404 http status code
And the 404 error page should be shown with a response code of 404
And the URL path should be still be /Test/Fail
Scenario: Explicitly return a 404 result from application code
Given a route /test/ok/{id} is defined
And the resource for id = 5 does not exist
When we navigating to ~/Test/Ok/5
and the action returns a HttpStatusCodeResult(HttpStatusCode.NotFound)
Then the on error event should be raised by XYZ with path information and 404 http status code
And the 404 error page should be shown with a response code of 404
And the URL path should be still be /Test/Fail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment