BlockLeftTop, PRELOAD BlockLeftBottom, PRELOAD BlockLeftStretch, PRELOAD BlockTop, PRELOAD BlockBottom, PRELOAD BlockStretch, PRELOAD BlockRightTop, PRELOAD BlockRightBottom, PRELOAD BlockRightStretch, PRELOAD
DeltaEngine

Unit testing for web sites

by Benjamin Nitschke 13. April 2007 08:42
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);
}

Comments are closed
Disclaimer: The opinions expressed in this blog are own personal opinions and do not represent the companies view.
© 2000-2011 exDream GmbH & MobileBits GmbH. All rights reserved. Legal/Impressum

Poll

Which platform should Soulcraft be released on next?











Show Results Poll Archive

Recent Games

Soulcraft

Fireburst

Jobs @ exDream

Calendar

<<  April 2014  >>
MoTuWeThFrSaSu
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011