Blogger :
ASP.NET Team Blogs
All posts :
All posts by ASP.NET Team Blogs
Category :
ASP.NET
Blogged date : 2008 Jul 26
In this tip, I demonstrate how you can unit test ASP.NET MVC views without running a Web server. I show you how to unit test views by creating a custom MVC View Engine and a fake Controller Context. The more of your web application that you can test, the more confident that you can be that changes to your application won’t introduce bugs. ASP.NET MVC makes it easy to create unit tests for your models and controllers. In this tip, I explain how you also can unit test your views. Creating a Custom View Engine Let’s start by creating a custom View Engine. Listing 1 contains the code for a really simple View Engine named, appropriately enough, the SimpleViewEngine. Listing 1 – SimpleViewEngine.vb (VB.NET) Imports System Imports...(
read more)