Monday, July 19, 2004

MbUnit (2.16.1) has now the ability to load and run NUnit (and csUnit) assemblies without recompilation.

How it works

Jamie Cansdale (NUnitAddin) sent me some classes he was using in his Addin to execute NUnit assemblies. Thank you Jamie :). When a type is explored, it looks into the referenced assemblies for NUnit.Framework.dll or csUnit.Framework.dll. If found, it thens extracts the TestFixtureAttribute type and tests if the type is tagged with it. A couple more details and there you have NUnit tests run by MbUnit...

Sample:

The following sample fixture is a standard NUnit fixture:

using System;
using NUnit.Framework;
namespace MbUnit.Tests.Core.FrameworkBridges
{
    [TestFixture]
    public class NUnitFrameworkTest
    {
        [TestFixtureSetUp]
        public void TestFixtureSetUp()
        {
            Console.WriteLine("TestFixtureSetUp");
        }
        [SetUp]
        public void SetUp()
        {
            Console.WriteLine("SetUp");
        }
        [Test]
        public void Test()
        {
            Console.WriteLine("Test");
        }
        [Test]
        public void AnotherTest()
        {
            Console.WriteLine("Another test");
        }
        [Test]
        [ExpectedException(typeof(AssertionException))]
        public void ExpectedException()
        {
            Assert.Fail("Should be intercepted");
        }
        [Test]
        [Ignore("Testing ignore")]
        public void Ignored()
        {
            Assert.Fail("Must be ignored");
        }
        [TearDown]
        public void TearDown()
        {
            Console.WriteLine("TearDown");
        }
        [TestFixtureTearDown]
        public void TestFixtureTearDown()
        {
            Console.WriteLine("TestFixtureTearDown");
        }
    }
}

The  fixture is loaded and executed by MbUnit and the reports shows:

posted on Tuesday, July 20, 2004 2:10:00 AM UTC  #    Comments [12]
Monday, June 06, 2005 5:48:12 PM UTC
I know <a title="MbUnit, Generating Unit Testing and Model Based Testing Framework for .NET Framework" href="http://mbunit.tigris.org" target="_blank">MbUnit</a> and nunit are neck and neck in functionality and quality. Is there a reason to use one over the other?
<br>
<br>by the way good stuff on this blog been a fan for a month or so now
Jerrad Anderson
Monday, June 06, 2005 5:48:12 PM UTC
Ok, here are the pro's of NUnit,MbUnit from my biased point of view (I'll keep as objective as I can).
<br>
<br>NUnit Pro's:
<br>-------------
<br>
<br>NUnit is more mature and stable, which has been adopted widely by the .Net community: it is safe and robust.
<br>
<br>NUnit GUI is more intuitive and evolved that <a title="MbUnit, Generating Unit Testing and Model Based Testing Framework for .NET Framework" href="http://mbunit.tigris.org" target="_blank">MbUnit</a>.
<br>
<br>NUnit supports FixtureSetup, FixtureTearDown,
<br>
<br><a title="MbUnit, Generating Unit Testing and Model Based Testing Framework for .NET Framework" href="http://mbunit.tigris.org" target="_blank">MbUnit</a> Pro's:
<br>-------------
<br>
<br><a title="MbUnit, Generating Unit Testing and Model Based Testing Framework for .NET Framework" href="http://mbunit.tigris.org" target="_blank">MbUnit</a> supports more &quot;exotic&quot; attributes such as TypeFixture, DataFixture, etc...
<br>
<br><a title="MbUnit, Generating Unit Testing and Model Based Testing Framework for .NET Framework" href="http://mbunit.tigris.org" target="_blank">MbUnit</a> is more extendible: In essence, <a title="MbUnit, Generating Unit Testing and Model Based Testing Framework for .NET Framework" href="http://mbunit.tigris.org" target="_blank">MbUnit</a> is an designed to be extended with new fixtures types, test decorators, etc... It is relatively easy to write and use a new fixture in <a title="MbUnit, Generating Unit Testing and Model Based Testing Framework for .NET Framework" href="http://mbunit.tigris.org" target="_blank">MbUnit</a> without recompiling the Core
<br>
<br>Comments ?
Jonathan de Halleux
Monday, June 06, 2005 5:48:13 PM UTC
Thanks, I'm still really interested in autogenerating tests. does <a title="MbUnit, Generating Unit Testing and Model Based Testing Framework for .NET Framework" href="http://mbunit.tigris.org" target="_blank">MbUnit</a> or Nunit do that better.
<br>
<br>I read somewhere that Nunit's creator (jamie right?) had gotten a <a title="CodeSmith" href="http://www.ericjsmith.net/codesmith/" target="_blank">CodeSmith</a> template to work that would generate tests.
<br>
<br>I read somewhere on this blog that you could also do that but then saw that you were releasing something else that did it.
<br>
<br>But I haven't found any info on any of it
Jerrad Anderson
Monday, June 06, 2005 5:48:13 PM UTC
Love the datafixture by the way. I can't wait to start doing database unit testing.
Jerrad Anderson
Monday, June 06, 2005 5:48:13 PM UTC
Jamie Cansdale is the creator of <a title="" href="http://weblogs.asp.net/nunitaddin/" target="_blank">NUnitAddIn</a>. If you are looking for a Unit test generator. You are on the right spot. Try my <a title="Reflector" href="http://www.aisto.com/roeder/dotnet/" target="_blank">Reflector</a>.Graph addin.
Jonathan de Halleux
Monday, June 06, 2005 5:48:14 PM UTC
It looks like you added support for TestFixtureSetup (from the example mentioned above). Is that right? How about refactoring nUnit code base rather than creating brand new testing framework?
sreenivas
Monday, June 06, 2005 5:48:14 PM UTC
It is impossible. NUnit architecture is too restrictive. Why should there be one unit test framework on .Net market ?
Jonathan de Halleux
Monday, June 06, 2005 5:48:15 PM UTC
Peli's Blog
Monday, June 06, 2005 5:48:15 PM UTC
Peli's Blog
Monday, June 06, 2005 5:48:15 PM UTC
I am using Nunit. And would like to use <a title="MbUnit, Generating Unit Testing and Model Based Testing Framework for .NET Framework" href="http://mbunit.tigris.org" target="_blank">MbUnit</a> for using the feature of muliti-Threading uinsg the attributed. does Nunit provide this? is it a good thing to move to <a title="MbUnit, Generating Unit Testing and Model Based Testing Framework for .NET Framework" href="http://mbunit.tigris.org" target="_blank">MbUnit</a>?
<br>
<br>My existing unittests use Assertion.AssertEquals() from nunit.
<br>
<br>but <a title="MbUnit, Generating Unit Testing and Model Based Testing Framework for .NET Framework" href="http://mbunit.tigris.org" target="_blank">MbUnit</a> does not this. <a title="MbUnit, Generating Unit Testing and Model Based Testing Framework for .NET Framework" href="http://mbunit.tigris.org" target="_blank">MbUnit</a> Said the assemblies will compile not need to change the source code? is that true? can I use by Nunit Tests in <a title="MbUnit, Generating Unit Testing and Model Based Testing Framework for .NET Framework" href="http://mbunit.tigris.org" target="_blank">MbUnit</a>
<br>
<br>Jinesh
jin
Monday, June 06, 2005 5:48:16 PM UTC
&gt;MbUnit Said the assemblies will compile not need to change the source code?
<br>
<br>Yes this is true. You can use NUnit tests and <a title="MbUnit, Generating Unit Testing and Model Based Testing Framework for .NET Framework" href="http://mbunit.tigris.org" target="_blank">MbUnit</a> in the same assembly, <a title="MbUnit, Generating Unit Testing and Model Based Testing Framework for .NET Framework" href="http://mbunit.tigris.org" target="_blank">MbUnit</a> will run both.
<br>
<br>&gt;Assertion.AssertEquals()
<br>
<br>This is just a sugar for Assert.AreEqual, so it is just a matter of writing a wrapper around that method.
<br>
<br>I'm not sure I'm qualified to answer your question since I am the creator of <a title="MbUnit, Generating Unit Testing and Model Based Testing Framework for .NET Framework" href="http://mbunit.tigris.org" target="_blank">MbUnit</a> so my opinion on it is biased.
Jonathan de Halleux
Monday, June 06, 2005 5:48:16 PM UTC
Wow, superb!
<br>Thanks.
Diana
Comments are closed.