What is the best method to test controllers in ASP MVC? (mocking frameworks, IoC, Selenium/Watir/Watin …)
What is the best method to test controllers in ASP MVC? (mocking frameworks, IoC,
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Testing MVC controllers would fall into the Unit Tests when you look at the Test Pyramid. I personally prefer the following tools for Unit Testing:
NUnit – Because it’s a far more mature testing framework when compared to MSTest and there’s a lot of useful add-ons that integrate with it such as Resharper.
Moq is a good .NET Framework Mocking Library
Unity is a great Dependency Injection framework which you can download from Codeplex and supports Constructor, Property and Method injection.
As far as writing code for automated browser testing goes, I have had experience with WebDriver is a great tool, however I classify automated browser tests as acceptance tests and hence less related to testing MVC Controllers in isolation.
Another great tool for Acceptance Testing is SpecFlow which is definitely worth a look if you need to do Acceptance Testing and works very nicely in an Agile environment.