asp.net mvc - MVC Advantages of Unit Testing Controllers -
my application has unit test domain layer know pros/cons of unit testing controller
and test cases should 1 write when testing controllers.
thanks
it depends.
validation, redirection, temporary messages , on can occur in controllers. argue these operations should tested models.
on other hand, should aiming 'fat model, skinny controller' mindset. tend make sure controllers dumb possible. put few end end tests around features care (selenium, cucumber etc...) , these enforce controllers correct. developing feature list items. if end end test of feature fine, controller fine. if breaks you'll know you've introduced regression. in combination have tests check correct views rendered , correct response occurs - redirection, json etc... more testing on controller , have logic in wrong place.
in asp.net mvc2 steve sanderson makes excellent points above reasoning. recommend it. con not having these simple controller tests open codebase, make change , break app. long correct views/responses occur app still functionally intact.
i should add testing service invoked within controller correct parameters trivial, , quick may whether or not test controllers indirectly. tend favour approach overall. full answer question yes, test controllers ;)
Comments
Post a Comment