Good News / Bad News

The good news is the the first major release of NUnitAddin for quite some time is out (version 0.5 build 105).  The bad news is that it only works if the .NET Framework 1.1 is installed.  It works with VS.NET 2002 and 2003, but only if 1.1 is there.  So far the issue has defeated me.  It looks like a NullReferenceException is being thrown deep in the bowels of .NET Remoting.  The exception is being thrown by the NUnitAddin.TestRunner.Server program.  If anyone can find the problem I would be hugely grateful.  You can set a breakpoint in the source and use the new 'Run With... Debugger' feature to step into the offending code.  Good luck... ;)

Here are some quick notes on Ad Hoc ASP.NET testing...

After you’ve installed the addin, the assembly that defines the attributes can be found here...

Program Files\NUnit Addin\NUnitAddin.TestRunner.Web\NUnitAddin.TestRunner.Web.dll

Once you’ve linked to that, define an .aspx file with a code behind that looks something like following.  You should then be able to right click and ‘Run Test(s)’ anywhere in the white space inside the 'test()' method.

using NUnitAddin.TestRunner.Web;

[Page("Test.aspx")]
public class Test : System.Web.UI.Page
{
   
private void Page_Load(object sender, System.EventArgs e)
    {
        Debug.WriteLine("Page_Load");
    }

    [Query("name=value"), Event("PreRender")]
   
private void test()
    {
        Debug.WriteLine("debug output...");
        Debug.Assert(Request.QueryString["name"] == "value");
    }

    #region Web Form Designer generated code
}

Each code behind class you want to test must have a Page attribute on the class.  The Query and Event attributes are optional and can appear on either the class or the test methods.  Once you’ve done this you can right click and run methods.  You can also right click and run inside the class but outside of any methods.  This will render the page, sending any exceptions to the test window.

You’ll find the test runner modifies the ‘Web.config’ file when the test is run.  This is to add a custom IHttpModule (to do the interception).  This is what the VS.NET warning about a file changing is about.  I need to find a fix for this.

Let me (and the rest of the world ;) know how you get on.

PS. A lot has changed in the 0.5 release.  Don't be surprised if there is the odd issue (but please tell me about it).  The latest 0.4 build is pretty stable, but doesn’t have any of the ASP.NET testing features.

2 Comments

  • Could you be more specific in what kind of exception is thrown en how to reproduce. (Perhaps a specific unit test would be nice :-))I would love to help but can't reproduce the problem. I only run 1.0 framework on my machine, so according to your posting I should have a problem right?.

  • I sussed the problem in the end. The problem occured when I passed a remoted object over an app domain boundry. This works in .NET 1.1 (it seems it implicitly register a channel) but non in 1.0. I fixed it by creating a proxy for the object and passing this into the other app domain. This seems to work fine, with the added bonus of not having any registered remoting channels in the test process.





    Thanks for your interest. I hope it continues to work for you! I seem to break it every so often. The test runners are in need of some unit tests themselves.

Comments have been disabled for this content.