Unit Testing ASP.NET Pages

You may need to create a unit test that calls older web code (code that is not segmented like MVC or Web API). You might also just want to create tests that call specific web pages and validate the results. Sometimes you need access to Page and Session objects in your tests, for example. In this case, you can create an ASP.NET unit test. These tests are configured to be hosted by a web server (local or IIS) and can call directly into your pages and ASP.NET environment.

To get started, add a new test project to your web solution (or create a new solution and project designed to test your website). You will also need the attribute classes found in the Microsoft.VisualStudio.TestTools.UnitTesting.Web namespace. No need ...

Get Microsoft Visual Studio 2015 Unleashed, Third Edition 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.