Active TopicsActive Topics  Display List of Forum MembersMemberlist  CalendarCalendar  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin


 One Stop Testing ForumTypes Of Software Testing @ OneStopTestingUnit Testing @ OneStopTesting

Message Icon Topic: ASP.NET unit testing--NUnitAsp

Post Reply Post New Topic
Author Message
ashwini_123
Senior Member
Senior Member


Joined: 23Jan2008
Online Status: Offline
Posts: 226
Quote ashwini_123 Replybullet Topic: ASP.NET unit testing--NUnitAsp
    Posted: 05Feb2008 at 9:32pm

Hi all,

I'm making it official: I am no longer maintaining or supporting NUnitAsp.

I've been neglecting NUnitAsp for several years, so I doubt this is a surprise. I originally wrote NUnitAsp in 2002 (starting with a seed provided by Brian Knowles), before .NET was even out of beta, to solve the problem of unit testing ASP.NET code for a portal application. As the portal grew more complex, so did NUnitAsp. But this approach always led to holes in NUnitAsp--the features of ASP.NET I didn't use didn't get any love. One big example: I always worked strictly in the ASP.NET component model, so my pages never had more than one form and I didn't use HTML or Javascript directly.

That project ended years ago, but I kept NUnitAsp alive, even though I haven't written any ASP.NET code for a long time. The NUnitAsp v2.0 release last year was my last attempt to fill in the big holes. Now it supports multiple forms, has a simpler syntax, and it tests HTML as well as ASP.NET server-side components.

NUnitAsp still has some dramatic flaws: no support for Javascript, tests running in a different process than ASP.NET, difficulty setting up sessions. Most people ended up using it for acceptance testing, rather than unit testing, and Selenium, Watir, and the like are better for that. Most folks "in the know" are using presentation layers to make ASP.NET so thin that a tool like NUnitAsp isn't helpful.

Despite these flaws, I think NUnitAsp is an interesting tool. I'm proud of the code and the API. If nothing else, it's a good example of what a dedicated agilist will do when faced with a brand-new platform: he finds a way to unit test it.


NUnitAsp is a tool for automatically testing ASP.NET web pages. It's an extension to NUnit, a tool for test-driven development in .NET.

Once you have an automated suite of tests, you'll never go back. It gives you incredible confidence in your code. That confidence allows you to code much faster, because you can make risky changes secure in the knowledge that your tests will catch any mistakes.

NUnitAsp is for unit testing ASP.NET code-behind only. It's meant for programmers, not QA teams, and it's not very good for QA-style acceptance tests. It only tests server-side logic. JavaScript and other client-side code is ignored. But if you're using ASP.NET, it's an essential part of your programmers' toolset.

NUnitAsp is freely available under the MIT license.

How It Works

NUnitAsp is a class library for use within your NUnit tests. It provides NUnit with the ability to download, parse, and manipulate ASP.NET web pages.

With NUnitAsp, your tests don't need to know how ASP.NET renders controls into HTML. Instead, you can rely on the NUnitASP library to do this for you, keeping your test code simple and clean. For example, your tests don't need to know that a DataGrid control renders as an HTML table. You can rely on NUnitAsp to handle the details. This gives you the freedom to focus on functionality questions, like whether the DataGrid holds the expected values.


Simply speaking, NUnitAsp makes it very easy to unit test ASP.NET web pages.

[Test]
public void TestExample()
{
   // First, instantiate "Tester" objects:
   LabelTester label = new LabelTester("textLabel");
   LinkButtonTester link = new LinkButtonTester("linkButton");

   // Second, visit the page being tested:
   Browser.GetPage("http://localhost/example/example.aspx");

   // Third, use tester objects to test the page:
   Assert.AreEqual("Not clicked.", label.Text);
   link.Click();
   Assert.AreEqual("Clicked once.", label.Text);
   link.Click();
   Assert.AreEqual("Clicked twice.", label.Text);
}

NUnitAsp can test complex web sites involving multiple pages and nested controls. The common ASP.NET controls are supported (see complete list below), and support for additional controls is easy to add.




Post Resume: Click here to Upload your Resume & Apply for Jobs

IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.297 seconds.
Vyom is an ISO 9001:2000 Certified Organization

© Vyom Technosoft Pvt. Ltd. All Rights Reserved.

Privacy Policy | Terms and Conditions
Job Interview Questions | Placement Papers | Free SMS | Freshers Jobs | MBA Forum | Learn SAP | Web Hosting