A quick how-to on setting up a MbUnit fixture and running it with TestDriven.NET.
In this page, we will show how to create a new test project, set it up for MbUnit and use TestDriven.NET to the tests it contains.
Step 1: Create a new assembly (preferably a console)
The first step to take is to create a new assembly project. Since MbUnit is a .NET project, it does not matter wether you are using C# or VB.NET
Create a console application instead of an Assembly project because MbUnit can easily make this assembly self-execute his tests (see SelfExecutableTestAssemblies
Step 2: Add MbUnit references
The binaires of MbUnit are located in the following folder:
The core assembly of the framework is "MbUnit.Core.dll". This assembly contains all the functionalities to create fixture but it does not contain any fixture as such. Therefore, you also need to add "MbUnit.Framework.dll" which contains a large number of fixture types.
Hence, you need to add the following assemblies to get started:
Step 3: Add your first TestFixture
- Create a new class (MyFirstTest)
- Add the imports for MbUnit. MbUnit.Core.Framework will give you the Assert classes while MbUnit.Framework contains the fixture types
- Create a classic test fixture like in other TDD frameworks. In this example, we will create a TestFixture with two tests. One successfull and another failing.
public class MyFirstTest
public void Success()
public void Failure()
throw new Exception("boom");
Step 4: Execute a single Test
With TestDriven.NET, you have to capability of executing any test or fixture that you want. The logic is simple: the location where you click sets the scope of the tests. For example, if you right-clik anywhere in a test method and hit 'Run Tests', this test will be executed solely.
- Right click inside Success method as depicted below. Your computer should start doing some noise
- TestDriven.NET will show the output window and the result of the execution as shown below. One can see the number of tests, success, failures, etc...
By default, MbUnit also renders the result in an Html report. You can see the link to this report at the end of the output. In order to see the report, you have to Ctrl + click on the url.
Step 5: Execute a single Fixture
As mentionned above, the location you click sets the scope of the tests. Therefore, if you trigger 'Run Tests' while clicking inside a fixture (but outside of the method), you will run all the tests from that fixture as the fixtures shown below:
Step 6: What's next ?
- You can also execute the tests from a namespace or an assembly using the same logic.
- You can make your console application execute the tests it contains. See [SelfExecutableTestAssemblies].