# Monday, November 15, 2004
posted on Monday, November 15, 2004 2:48:00 PM (Pacific Standard Time, UTC-08:00)  #    Comments [3]
# Wednesday, October 20, 2004

This new functionality enables you to specify a tabular list of test cases that are to be feeded to the test method. Let me illustrate that with the floating point division testing (as in the FIT framework Simple Example ):

numerator denominator quotient()
1000 10 100.0000
-1000 10 -100.0000
1000 7 142.85715
1000 .00001 100000000
4195835 3145729 1.3338196

You can now translate this directly to C# in MbUnit using the RowTestAttribute and the RowAttribute:

[TestFixture]
public class DivisionFixture
{
    [RowTest]
    [Row(1000,10,100.0000)]
    [Row(-1000,10,-100.0000)]
    [Row(1000,7,142.85715)]
    [Row(1000,0.00001,100000000)]
    [Row(4195835,3145729,1.3338196)]
    public void DivTest(double numerator, double denominator, double result)
    {
        Assert.AreEqual(result, numerator / denominator, 0.00001 );
    }
}

Of course, these tests are not very well targeted because we do not test the “special” floating point values such as 1,0,double.MaxValue, double.MinValue, NaN but you get the picture.

What if a test should throw ? In that case, you can specify the exception type as an additional parameter in the RowAttribute constructor:

    [Row(1,0,0, ExpectedException = typeof(ArithmeticException))]
    public void DivTest(double numerator, double denominator, double result)
    {...}

The final output of the tests is as follows where you can see that 5 tests (one per row) were generated and executed.

Info: Found 5 tests
Info: [assembly-setup] success
Info: [success] RowTestDemo.DivTest(0)
Info: [success] RowTestDemo.DivTest(1)
Info: [success] RowTestDemo.DivTest(2)
Info: [success] RowTestDemo.DivTest(3)
Info: [success] RowTestDemo.DivTest(4)
Info: [assembly-teardown] success
Info: [reports] generating HTML report
posted on Wednesday, October 20, 2004 7:30:00 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [7]
# Monday, October 18, 2004

I'm slowly catching up with putting some order in the MbUnit documentation. Therefore, MbUnit has now a Wiki (FlexWiki powered) part of the TestDriven.NET wiki. Feel free to contribute...

http://www.testdriven.net/wiki/default.aspx/MyWiki.MbUnit

posted on Monday, October 18, 2004 5:36:00 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [12]
# Saturday, October 16, 2004

MbUnit has now a basic support for loading fixture and tests based on their names, such fixture are called Naked Fixtures . Although this may look like a step backward in functionality, this can be handy in particular situations. For example, if you don't want to reference any test framework, this is a good solution because it does not require any type or attribute.

Naming rules

  • class name must end with “Fixture“
  • fixture setup method must be named “TestFixtureSetUp“
  • fixture teardown method must be name “TestFixtureTearDown“
  • setup method must be named “SetUp”
  • teardown method must be named “TearDown”
  • test methods must end with “Test”
  • all rules are case sensitive

Limitations

  • [Update: decorators are supported].
  • no combinatorial tests

QuickStart

 Below are two fixture. The first uses attributes and should be familiar to you. The second is it's naked equivalent:

[TestFixture]
public class ClassicFixture
{
    [TestFixtureSetUp]
    public void TestFixtureSetUp()
    {
        Console.WriteLine("TestFixtureSetUp");
    }
    [SetUp]
    public void SetUp()
    {
        Console.WriteLine("SetUp");
    }
    [Test]
    public void First()
    {
        Console.WriteLine("Test1");
    }
    [Test]
    public void SecondTest()
    {
        Console.WriteLine("Test1");
    }
    [TearDown]
    public void TearDown()
    {
        Console.WriteLine("TearDown");
    } 
    [TestFixtureTearDown]
    public void TestFixtureTearDown()
    {
        Console.WriteLine("TestFixtureTearDown");
    }
}

Naked version:

public class NakedFixture
{
    public void TestFixtureSetUp()
    {
        Console.WriteLine("TestFixtureSetUp");
    }
    public void SetUp()
    {
        Console.WriteLine("SetUp");
    }
    public void FirstTest()
    {
        Console.WriteLine("Test1");
    }
    public void SecondTest()
    {
        Console.WriteLine("Test1");
    }
    public void TearDown()
    {
        Console.WriteLine("TearDown");
    }
    public void TestFixtureTearDown()
    {
        Console.WriteLine("TestFixtureTearDown");
    }
}
posted on Saturday, October 16, 2004 10:43:00 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [1]
# Friday, October 15, 2004

TestDrivent.NET, which contains MbUnit, QuickGraph, TestFu and Refly, has gone RC2 .

See http://www.testdriven.net/wiki/default.aspx/MyWiki.DownLoad

 

posted on Friday, October 15, 2004 2:37:00 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [4]
# Thursday, October 14, 2004

Check out this new Reflector addin that creates diffs. Very cool...

http://codingsanity.blogspot.com/2004/10/reflector-diff.html

posted on Thursday, October 14, 2004 5:14:00 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [7]
# Friday, October 08, 2004

PDFizer: A XHTML to PDF converter: with this library, you can transform simple XHTML pages to nice and printable PDF files. This project is based on the excellent webzine article "Pdfizer, a dumb HTML to PDF converter, in C#" written by Jonathan de Halleux.

Cool, my PDFizer project has been resurected. If you are looking for an easy way to convert HTML pages into PDF, you might well be interrested by that one.

posted on Friday, October 08, 2004 9:12:00 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [3]
# Tuesday, October 05, 2004

MutantBuild is the back bone behind TestDriven.NET / MbUnit compilation. Jamie Cansdale has published an installer that will let you play with it. Anybody automating VS.NET solution should have a look at this.

posted on Tuesday, October 05, 2004 1:14:00 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [4]
# Monday, October 04, 2004

Sometimes, a unit test does not fail but does not succeed entirely: making it fail is too extreme and on the other hand, letting him succeed would make you miss the issue. Therefore, MbUnit now supports warnings:

  • A warning can be emited in any test case using Assert.Warning methods,
  • A warning does not make test fail,
  • Warnings are recorded in the test report (in the Html report, they are displayed right after the fixture summary),
  • Multiple warnings can be outputed per test

QuickStart

This fixture shows 2 tests with warnings:

using System;

using MbUnit.Core.Framework;

using MbUnit.Framework;

namespace MbUnit.Demo

{

[TestFixture]

public class WarningTest

{

[Test]

public void Warning()

{

Assert.Warning("Be wary");

}

[Test]

public void Warning2()

{

Assert.Warning("Something weird happened");

}

}

}

The corresponding html report looks like this:

posted on Monday, October 04, 2004 10:42:00 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [3]
# Sunday, October 03, 2004

This is the last entry on my dev box before I pack it and send to the US Do not expect much responsivness during the 2 next weeks until I get it back.

posted on Sunday, October 03, 2004 1:29:00 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [3]