Testing ASP.NET MVC Applications

The ASP.NET team is on schedule to release the new MVC (Model-View-Controller) framework sometime early in 2009. The MVC framework gives Web developers a new way to create Web apps. In my mind, ASP.NET Web Forms are useful when I want a Web app that gives the appearance of a single Web page. The new MVC framework is especially useful when your Web application consists of a collection of related, but different-looking, pages. Think of an e-commerce system like amazon.com for example. Anyway, I’m currently creating a training class "VS 473 – Testing ASP.NET MVC Applications" for contract and full-time software engineers working at Microsoft. I have found that the design of the MVC framework really lends itself well to test automation. The MVC framework supports unit testing, but unit testing is primarily a development activity; using unit testing does not mean you can omit thorough testing of MVC apps. The screenshot below shows an ASP.NET MVC application and a proof-of-concept of some lightweight test automation. The MVC app is a slight variation of the Task List application, an excellent example written by Microsoft’s Stephen Walther, from the tutorials section of the ASP.NET MVC Web site. The test automation running in the command shell uses a GET request to send information to the MVC application, instructing the app to mark the "Work on second task" task item as Complete. The test automation fetches the HTTP response from the GET request and examines the response for HTML code that indicates the MVC app responded correctly. Very, very simple. I took the screenshot just before the MVC Web app refreshed to show the task had been marked as Complete. The investigation demo showed me that writing test automation to complement manual testing of ASP.NET MVC applications will be very easy, powerful, and efficient.


This entry was posted in Software Test Automation. Bookmark the permalink.