testing Asp.Net MVC sites with Ivonna
Sunday, May 17, 2009 4:21:30 PM
While Asp.Net MVC architecture is widely praised for its testability, it is seldom mentioned that the Views are still untestable. It is believed that you don't need to test your views since they are "dumb", and it's just too hard anyway. However, string-based ViewData and unevitable foreach pieces make the View fragile, and you just can't leave it untested.
While you can't have a Page instance with all its structured beauty, you can still test your MVC views with Ivonna. Remember, however, that the usual session.GetPage() won't work: you have to use something like session.ProcessRequest(new WebRequest("LogOn")), for example. Then use response.BodyAsString to get the raw HTML output, or other WebResponse to check for redirects or response status.
While this is all possible with client-side frameworks, the mere fact that we are in-process makes it possible to mock stuff. For example, you can mock the Controller, or the Model, or, say the membership provider.