tdd - How can I unit test or integration test for 404 - Not Found? -
my team writing content-managed web-hosting application in asp.net mvc 2 s#arp architecture framework. i'm using specflow , watin integration testing, , nunit unit testing.
i have custom controller factory locates page in database based on url , site, , loads proper controller , action. loads error controller when page (or site) not found in database.
i want write either unit test or integration test validates 404 page displayed when url invalid. watin cannot check response header, cannot accurately ensure actual 404 page loaded. may eliminate integration test solution.
i'm new tdd , bdd, may missing obvious. also, retro-fitting tests project, makes more difficult.
thanks in advance.
normally when write bdd scenarios, write them user's perspective.
if user ordinary person, don't care whether header genuine 404. they'd prefer page giving them clear , useful message. write scenario check clear , useful message.
given no section on unicorns exists when user browses horses , changes url unicorns user should told no such page exists.
bdd isn't testing. it's conversations let discover other things haven't thought of, , developing common understanding of should happen. instance, happens when ordinary user tries access admin page? should "access denied" or not know page there? if page deleted? discussions more useful trying pin down.
if 404 associated particular message user, can unit-test appropriate response matches. drastically reduce chances of accidentally sending wrong code message in future, , can focus on real benefit.
Comments
Post a Comment