Unit testing ASP.NET MVC Controller methods through concrete class or interface


Unit testing ASP.NET MVC Controller methods through concrete class or interface



I'm writing some unit tests for some controller methods in my project and am wondering whether to test against the controller class itself or an interface of that controller.

Should I be creating an interface for each controller and run my unit tests against that?


Unit testing with EF4 “Code First” and Repository

1:

Passing nested arrays to asp.net mvc using jQuery's $.ajax
You should test against the concrete conroller as this is where your site specifit code is occuring. How to fake Http post?You should inject service or data access code into the controller via their interfaces so this you must mock out the data access layer.. MVC Ajax PartialViews not firing Javascript - should I use Spark?
Grab data from table, join string from two columns, display in MVC selectListServing a file generated dynamically by the model, in ASP.NET MVC

2:

ASP.NET MVC: ActionLink vs bare url
Do you have a need to treat your controllers as interfaces (quite unlikely I would of thought)? if so test against that. meaning of “strongly typed view”If not, then directly test against the controllers..


66 out of 100 based on 26 user ratings 346 reviews

#