How To Build an NUnit Addin


Since version 2.2.x of NUnit it was possible to build your own core extensions, but this feature was experimental. With the latest release Addins are officially supported. Core extensions can customize NUnit’s internal behavior such as the creation of tests and their execution.

Writing an Addin

An Addin needs to implement the interface NUnit.Core.Extensibility.IAddin, which can be found in the assembly “nunit.core.interfaces”. Additionally the NUnit.Core.Extensibility.NUnitAddinAttribute must be applied to your Addin class. The attribute parameters Name and Description represent the name of the extension and a description of what it does. You can leave ExtensionType at its default value (ExtensionType.Core), because NUnit supports only core extensions by now. The interface NUnit.Core.Extensibility.IAddin has only one method which is called Install. Your Addin class will install extensions at certain extension points, places where the NUnit functionality can be extended. To locate such extension points your Addin class uses the extension host, which is passed as parameter. The Install method returns true when your Addin was able to install your extensions, otherwise it returns false. A minimal Addin would look like this:

    using System;
    using NUnit.Core.Extensions;
        Description=”This Addin does not do anything.”)]
    public class MyAddin : IAddin
      public bool Install(IExtensionHost host)
        return true;

How to Install an Addin

After compiling the Addin copy the assembly to the bin/addins directory relative to the NUnit install directory. Start the NUnit GUI and you should see your Addin listed under Tools -> Addins…: MyAddin does not do anything useful. The next time I’ll show you how to write a test decorator.


IronRuby Follows IronPython


Great news for dynamic language enthusiasts: Microsoft will implement Ruby on top of .NET. It will be called IronRuby and it will use the new Dynamic Language Runtime (DLR), a great platform for authoring and hosting dynamic languages. You can see a demo here showing interoperation between Ruby, Python, JavaScript, and Visual Basic. The demo uses Silverlight, a browser plug-in for rich interactive web applications, as DLR host. Silverlight will run on all major browsers on both Mac OS X and Windows. Unfortunately this excludes all Linux browsers, but it seems that the Mono people are interested in implementing Silverlight for Linux. The best thing, however, is that Microsoft makes the source code of the DLR, IronPython, and IronRuby available as open source under the Microsoft Permissive License (a BSD-style license).