SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Matt Ward

NUnit 2.5 Support

SharpDevelop 3.1 now supports NUnit 2.5.

A summary of which NUnit version is supported by SharpDevelop is shown in the table below.

SharpDevelop 3.1 NUnit 2.5
SharpDevelop 3.0 NUnit 2.4.8
SharpDevelop 2.2.1 NUnit 2.4.7
SharpDevelop 1.1 NUnit 2.2

NUnit 2.5 Changes

NUnit 2.5 has changed quite substantially compared with the previous 2.4.8 release, as outlined in the NUnit 2.5 release notes. The problems that we had when migrating SharpDevelop's unit tests to NUnit 2.5 were as follows.

  1. Assert.IsInstanceOfType has been replaced by Assert.IsInstanceOf.

    Your code will still compile and work if Assert.IsInstanceOfType is used but you will get compiler warnings.

  2. NUnit.Framework.SyntaxHelpers namespace no longer exists.

    All classes that were in this namespace have been moved to the NUnit.Framework namespace.

  3. The Has.Count constraint no longer takes an integer parameter.

    To fix this problem replace code such as:

    Assert.That(classesCollection, Has.Count(1));

    With the following:

    Assert.That(classesCollection.Has.Count.EqualTo(1));
  4. Overriding a [TestFixtureSetUp] method in a derived class using the new keyword no longer works.

    Some of the SharpDevelop unit tests were overriding an abstract base test class [TestFixtureSetUp] method in a derived class by using the new keyword, as shown below.

    Base class:

    [TestFixtureSetUp] 
    public void SetUpFixture()
    {
    // Setup code.
    }

    Derived class:

    [TestFixtureSetUp] 
    public new void SetUpFixture()
    {
    // Extra setup code.
    base.SetUpFixture();
    }

    In NUnit 2.4.8 the SetUpFixture method in the derived class would be called when running the tests allowing it to execute some extra setup steps. In NUnit 2.5 the base class SetUpFixture method is called instead and the derived class method is never called. To resolve the problem we changed the base class so it used a virtual method and allowed the derived class to override this to execute its extra setup steps.

    Base class:

    [TestFixtureSetUp] 
    public void SetUpFixture()
    {
    BeforeSetUpFixture();
    // Setup code.
    }

    public virtual void BeforeSetUpFixture()
    {
    }

    Derived class:

    public override void BeforeSetUpFixture() 
    {
    // Extra setup code.
    }
Published May 10 2009, 05:46 PM by MattWard
Filed under:

Comments

 

sprocketonline said:

Downloaded latest 3.1 beta, but it currently crashes when running Extended NUnit console runner for NUnit 2.5.

July 4, 2009 2:17 PM
 

MattWard said:

Have you tried a newer 3.1 release?

If the same problem exists with a newer release then I will need more information, such as how does it crash exactly? What message is displayed?

July 4, 2009 8:47 PM
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.