Creating a Unit Test Project

The MS Test unit-testing framework is included with all paid editions of Visual Studio 2010 (it is not included in Visual Web Developer Express 2010); if you're using Visual Studio 2012, unit testing is even included in the free editions and contains a much-improved unit test runner. Although you can create unit test projects directly inside of Visual Studio, it can be a lot of work getting started with unit testing your MVC application. The ASP.NET MVC team included unit-testing capability in the New Project dialog for MVC applications, as shown in Figure 13.1.

By selecting the Create a Unit Test Project checkbox, you're telling the ASP.NET MVC New Project Wizard not only to create an associated unit test project, but also to populate it with a set of default unit tests. These default unit tests can help new users understand how to write tests against an MVC application.

Third-Party Unit-Testing Frameworks
The Test Framework combo box on the ASP.NET MVC New Project Wizard allows you to select which unit-testing framework you'd like to use. For users with the paid editions of Visual Studio, this will include a combo box, Visual Studio Unit Test, designed to be supplemented by third-party unit-testing frameworks. Check with your unit-testing framework of choice and see if it supports ASP.NET MVC.

Examining the Default Unit Tests ...

Get Professional ASP.NET MVC 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.