Just found this by accident:
NUnitAsp. Seems to be very useful. I was always wondering why
TestDriven.NET does not support testing web sites or services. It gives you the following message if you try to run tests from a website:
- Can't execute tests in 'Web Site' application.
There are probably other reasons why this does not work yet, but maybe it is possible to find a way around that. Currently I use a extra project and call the web site or web service from there with my custom methods. It looks much cleaner with
NUnitAsp. For me it would even be better if I could write and run unit tests directly on the website without that extra project. Maybe I should drop
Jamie Cansdale of TestDriven.NET a short message asking him for some support in the future for ASP.NET. There does not seem to be anything on his blog about ASP.NET yet, at least the search returned 0 results.
Here is a little example from NUnitAsp, which shows you how to test a label on a website:
[Test]
public void TestExample()
{
// First, instantiate "Tester" objects:
LabelTester label = new LabelTester("textLabel", CurrentWebForm);
LinkButtonTester link = new LinkButtonTester("linkButton", CurrentWebForm);
// Second, visit the page being tested:
Browser.GetPage("http://localhost/example/example.aspx");
// Third, use tester objects to test the page:
AssertEquals("Not clicked.", label.Text);
link.Click();
AssertEquals("Clicked once.", label.Text);
link.Click();
AssertEquals("Clicked twice.", label.Text);
}
