The intersection of technology and leadership

Getting NUnit ASP to work with .Net 2.0

On my current project we’ve been having a pretty good experience leveraging the NUnitASP library for automated testing of our website. In our second week of development, we noticed like many other people, that it is yet fully compatible with .Net 2.0 because of the way that ASP.Net now generates its javascript postback functions.

In the previous .Net version, ASP.Net seemed to generate a very simple function of the form of __doPostBack([targetId], [targetArguments]) that would effectively set two hidden variables (__EVENTTARGET and __EVENTARGUMENT respectively). In the current version, ASP.Net generates a much more complex javascript function (called WebForm_DoPostBackWithOptions) that I think is caused with use of any of the ASP validator components.

One work around that one person (Lance Ahlberg) found was to turn the “CausesValidation” property off for controls but this may or may not suit the way that you are developing your website. Looking at what the javascript generated does, I think that there must have been a better solution so I spent some time delving into the depths of NUnit ASP to find one.

The result is a patch to ControlTester.cs that allows the __EVENTTARGET and __EVENTARGUMENT to still be set by extracting out the appropriate values from the new WebForm_DoPostBackWithOptions javascript function. You can download the patch here but you have to build your own NUnit ASP, or wait until this is integrated with the next release. The ticket for my submission can be found here.

3 Comments

  1. Sam

    I suggest you look at other test frameworks for the web. NUnitAsp has gone stale a couple of years now. Check out WebAii at http://www.artoftest.com. It can automate both IE & FF with a managed API that works with Visual Studio

  2. Frederic Torres

    InCisif.net is an automation tool designed to implement client-side functional
    testing of web applications under Internet Explorer 6.x or 7.x, using the C#
    or VB.NET language with Visual Studio 2003, 2005 or express editions.

    – Record mode with interactive DOM viewer
    – XML report and test execution trace file.
    – XML Test/suite reporting api.
    – Specific methods to support AJAX applications
    – NUnit support (source code available)
    – TestDriven.net add-in support (source code available)
    – IronPython support

  3. David

    NUnitAsp has gone stale a couple of years now!!!

    It’s 2008 and having used it and many others such as selenium, it’s still the best one I have seen.

    It’s simple and it works. Stale! – My foot.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© 2024 patkua@work

Theme by Anders NorenUp ↑