2011/01/19

What's next?

Gallio/MbUnit v3.2.2 was released some days ago. And we've got many "thank you" for the resolution of this annoying CS1685 issue (thank you Graham for having fixed it).

Now what can you expect from the incoming releases of Gallio? The path to v3.3 is still long, but we plan to release several intermediate point releases with more fixes, more improvements and a lot of new features. In a random order, here is an overview of those future new nifty features:
  • Major performance improvements: We are in the process of replacing the XSLT-based engine which generates the test reports by a brand new and faster system based on Castle NVelocity. We also would like to do no longer rely on that damn slow .NET Remoting for IPC communications and to use the popular Google's Protobuf format instead. Those major changes should bring dramatic performance improvements while running the tests and formatting the test reports.
  • MbUnitCpp: a port of the MbUnit testing framework to the native unmanaged C++ realm; entirely integrated to the Gallio ecosystem. It’s not feature complete yet, but MbUnitCpp is already fully functional and available as part of the daily v3.3 builds. The wiki documentation is also very detailed already; with a comprehensive tutorial.
  • NHamcrest support: Graham Hay did port recently Hamcrest to C#. Assert.That is going to be extended to support that fluent API.
  • PartCover support: A new adapter for this excellent test coverage tool.
  • New assertions, new contract verifiers, and many other little enhancements (see draft release notes for detailed)
Some of those features are in fact fully or partially available in the v3.3 trunk already. Feel free to test them. Feedback and suggestions are always gratefully received.

And of course, we will continue to closely follow the continuous releases of the 3rd party tools that coexist in the Gallio ecosystem and to update the existing test adapters and plugins accordingly.

2011/01/13

Announcing Gallio and MbUnit v3.2.2

We are pleased to announce that a maintenance release of Gallio/MbUnit is now available. This release mainly contains many bug fixes and little enhancements. It fixes in particular this annoying CS1685 warning. Read the release notes for more details.

Please visit the Gallio website Downloads page to get the binaries, or grab them directly from here:

2010/12/03

Announcing Gallio and MbUnit v3.2.1

We are pleased to announce that a maintenance release of Gallio/MbUnit is now available. This release mainly contains many bug fixes and little enhancements. But it also features the long-awaited support to Jetbrains dotCover. See the release notes for more details.

Please visit the Gallio website Downloads page to get the binaries, or grab them directly from here:

2010/11/15

MbUnit v3 to support (N)Hamcrest

Recently, Graham Hay did port the well-known Hamcrest library to .NET. The new version of that library was judiciously ;) named NHamcrest. It is also fully integrated to Gallio/MbUnit with Assert.That.

Try it out by downloading the latest v3.3 daily build and give us feedback and suggestions.
[Test]
public void NHamcrestExample()
{
var array = new[] {"red", "green", "blue"};
Assert.That(array, Is.InstanceOf(typeof(string[])));
Assert.That(array, Has.Items(new[] { "green", "red" }));
Assert.That(array, Has.Item<string>(Starts.With("bl")));
}

2010/10/07

Testing Custom Data Source Attributes in MbUnit v3.2

In a recent post, I explained how to create a custom data source attribute for MbUnit. But before using it, it's certainly safer to test it. The method described below is the same as the one which is applied in the MbUnit test project itself. It is widely used to verify that the built-in attributes of MbUnit behave as expected. The principle is the following:
  1. Create a nested explicit sample test fixture which consumes the attribute under test. It must be marked as explicit, so that it will not be taken in account by the primary test runner.
  2. Create a regular unit test which launches an inner isolated test runner, and runs the sample fixture.
  3. Retrieve the output of the inner test runner and assert over the test log.
The Gallio framework has everything you need to create an isolated test runner. But in order to make the things easier, the Gallio SDK (you can find the SDK under %gallio_install_path%\sdk) contains a couple of handy helper classes for that very purpose. It provides in particular a BaseTestWithSampleRunner class that you can use as a base class of you main fixture, and a [RunSample] attribute to easily target the nested explicit sample fixtures.

Here is a simple example that shows how to test the [BooleanData] attribute that we did create last time.
[TestFixture, RunSample(typeof(SampleFixture))]
public class BooleanDataAttributeTest : BaseTestWithSampleRunner
{
[Test]
public void Test()
{
var runs = GetTestStepRuns(typeof(SampleFixture), "Test");
var logs = runs.Select(GetLog).Where(x => x.Length > 0);
Assert.AreElementsEqualIgnoringOrder(new[] { "value=True", "value=False" }, logs);
}

[TestFixture, Explicit]
internal class SampleFixture
{
[Test]
public void Test([BooleanData] bool value)
{
TestLog.Write("value={0}", value);
}
}
}
Want to know more? Be sure to read this page in the Gallio wiki.

2010/09/22

Announcing Gallio and MbUnit v3.2

We are pleased to announce the release of Gallio & MbUnit v3.2. Please visit the Gallio website download page. This is a major release with many new features and enhancements. See the release notes for more details.

Be sure to read Andy's blog post too.

2010/09/03

Writing Custom Data Source Attributes in MbUnit v3.2

The extensibility of the Gallio platform is simply amazing. You can virtually extend any part of the system. It goes from a simple plugin that provides new handy functionalities to a full-blown adapter for your fancy testing framework. Today, I would like to explain how easy it is to extend the MbUnit framework with a custom data source attribute.

MbUnit has many useful built-in data source attributes which might be used to create powerful data-driven tests. The most popular attributes are certainly [Row] and [Column].

Now let's imagine you get bored with writing that kind of tests:
[Test]
public void Mytest(
[Column(true, false)] bool flag1,
[Column(true, false)] bool flag2,
[Column(true, false)] bool flag3)
{
// ...
}
Imagine how beautiful would be the world if you could write the following instead:
[Test]
public void Mytest(
[BooleanData] bool flag1,
[BooleanData] bool flag2,
[BooleanData] bool flag3)
{
// ...
}
Unfortunately, this data source attribute does not exist in MbUnit.

So let's make it happen!

Creating a custom data source is very easy. Basically you simply need to derive from MbUnit.Framework.DataAttribute, and to override the virtual method PopulateDataSource.
[AttributeUsage(PatternAttributeTargets.DataContext, AllowMultiple = false, Inherited = true)]
public class BooleanDataAttribute : DataAttribute
{
protected override void PopulateDataSource(IPatternScope scope, DataSource dataSource, ICodeElementInfo codeElement)
{
dataSource.AddDataSet(new ValueSequenceDataSet(new object[] { true, false }, GetMetadata(), false));
}
}
That's all. Compile and run your test happily!

You might find more inspiration by examining the actual implementation of existing built-in attributes such as [EnumData] or [RandomStrings] which is slightly more complicated as it relies on the underlying Gallio data generation framework.

Next time, I will explain how to properly test you custom data source attribute by using the Gallio SDK.