Scott Hanselman has a great post on how to use the lightweight ASP.NET Web Server Cassini to unit test all sorts of things that need to be hosted by ASP.NET. His example shows how to do simple smoke test of an ASP.NET application by asserting that the response stream contains the world “Hello”. This is sufficient for simple smoke tests, but when testing more advanced functionality I use NUnitASP because of its great control tester library. Since NUnitASP uses a “browser” to retrieve an ASP.NET page and then parses it to find the controls, you can exchange Scotts basic smoke test method with a NUnitASP test case. Like this:
[Test]
public void SimpleTest() {
Browser.GetPage(new Uri(webServerUrl),page).ToString());
LabelTester label=new LabelTester("Label1",CurrentWebForm);
AssertVisibility(label,true);
}
Thanks for the great post Scott!