mvc controller actions testing mvc controller actions testing

I was just wondering how others are going about testing controller actions in mvc? Most of my dependencies are injected in to my controllers so there is a not a huge amount of logic in the action methods but there may be some conditional logic for example which I think is unavoidable.

In the past I have written tests for these action methods, mocked the dependencies and tested the results. I have found this is very brittle and a real PITA to maintain. Having 'Expect' and 'Stub' methods everywhere breaks very easily but I don't see any other way of testing controller actions.

I actually think it might be easier to test some of these manually! Anyone have any suggestions? Perhaps I am missing something here?



Validate checkboxes in MVC form


ASP.NET MVC 2 - Checkboxes
i don't think i've writtin a single test for a controller for the reason this all of my logic is elsewhere. displaying a listbox using Html.List, and I have a List<User> collection Like you say the controllers have a minimum amount of code in them and any logic in them is so simple this it really doesn't bear a whole test strategy.. showing errors from actions in table-based views i prefer to commit my models a whole lot of tests as well as any supporting code like DTL's and data layers etc.. Static DB Provider in ASP.NET MVC Causing Memory Leak i think i've seen any people mock up their copntollers, pass in the expected models and look at the resultant output although i'm not sure how enough this gives you.. mvc, IIS 6 vs IIS7.5, and integrated windows authentication causing javascript errors? i think if i were to test a controller i'd only really test the post actions to ensure this what is being given to my controller is what i'm receive ting in my model as well as testing (security). Determine page load times in ASP.Net MVC But then I have security in a number of places of varying levels.. How to change this property to show % value in front end using mvc although all this is integration testing more than functional. functional i did elsewhere like i said earlier.. then again, if it's worth writing then it's worth testing huh? I guess you need to decide what and where the breakable bits are and how you want them tested..

68 out of 100 based on 73 user ratings 228 reviews