Using The MbUnit GUI Runner
MbUnit proffers two applications for running tests against your code. The console runner discussed on this page and the windows-based application discussed here. You’ll find them both in the MbUnit installation directory; c:\program files\mbunit by default. From v2.4.1, the GUI runner can also be accessed by choosing MbUnit | MbUnit.GUI from the Start Menu. If you use a version prior to v2.4.1 and intend to use the GUI runner a lot, it might not be a bad idea to create a shortcut to it on your desktop or pin it to your start menu as it is not added to your start menu during installation.
Open the GUI by double-clicking on the executable or by running it from the command prompt. You’ll see the following.

The GUI runner opens by default with no test assemblies loaded. Typically, you’ll want to use it in the following manner.
- Load test assemblies into the runner either directly with the Assemblies |
Add Assemblies... menu option or as part of an already created MbUnit project
using File | Open Project. If you add the wrong test assembly, remove it with Assemblies | Remove Assemblies...

- Run all the tests using Tests | Run or by clicking the Run button at the
top of the right-hand window. The GUI will highlight those tests that failed in
red, those that passed in green, and those that were ignored in yellow. If you need to stop the test run, press the stop button on Tests | Stop.
If you want to run individual tests, first select the test from the tree on the left hand side, then right click the test and select Tests | Start Tests. Do the same for any subset of tests that you want to run. The test tree on the left shows the tests in an assembly divided five ways: by author, category, importance, namsepace, and the code class (type) that the tests are working on.

- For each test that has failed, at least one exception will have occurred. To see
the details of that exception, click on the test in question and the text of exception
will be displayed along with its stack trace in the right hand window under the
Exception tab (shown below). If your tests write to the command prompt or the error
console, you can click on the test and the corresponding output will be shown in
the Console.Out and Console.Error tabs on the right hand side of the GUI respectively.

- Do a bit more coding...
- If you write more tests to be run, compile the test assembly and reload it into the GUI with Assemblies | Reload.
- If you want to step through the test code as it is being executed, attach your debugger to the MbUnit.GUI process, set a breakpoint in the test code and run the test. If you want to step the code being tested, you won't need to attach your debugger to MbUnit.GUI. Just set the breakpoint on your code and run the test.
- Generate a report from the results of your last test run by choosing an option from the Reports menu.
- Save your MbUnit project for later use with File | Save Project As.
- Close the GUI or start testing a different project with either File | New Project or File | Open Project.
Context Menu Options
Selecting any node in the test tree and then right clicking it will produce a context menu with a standard set of options as follows
- Tests | Start Tests : Runs the selected test(s)
- Tests | Stop Tests : Stops the currently running test(s)
- Assemblies | Add Assemblies : Lets you add a new test assembly to the current test project
- Assemblies | Remove Assemblies : Lets you remove a new test assembly to the current test project
- Assemblies | Reload Assembly : Tells the GUI to reload an assembly into the project
- Clear Results : Clears all test results from the GUI
- Config | Load Config : Loads a pre-existing MbUnit project (*.mbunit) into the GUI
- Config | Save Config As : Save the current MbUnit project
- Report | * : Produces and displays a report generated against the result from the last test run. The report can be in xml, text, html or dox format.
- Ncover | Run : Runs the test(s) through nCover, a test code coverage analyser.
- Create nAnt Task (Clipboard) : Generates the correct nAnt command to run the whole MbUnit project and generate an HTML report. This is saved to the desktop to be added to your nAnt scripts.
- Create MSBuild Task (Clipboard) : Generates the correct MSBuild command to run the whole MbUnit project and generate an HTML report. This is saved to the desktop to be added to your MSBuild scripts.
Note that these last two options only produce scripts for the whole project rather than the test(s) selected.
Starting the GUI Runner from the Command PromptAt any point you can bring up a summary of this page by typing any of the following at the command prompt
MbUnit.GUI.exe /h
MbUnit.GUI.exe /help
Full Syntax
When starting the GUI runner from the command prompt, you can use the following syntax
MbUnit.GUI.exe {AssemblyToTest[...]|ProjectFile} [[/ap: assemblypath ] [/rt: reportType [/rf: reportpath ] [/rnf: reportname ] [/tr: transformpath ] [/sr ]] [/fc: categoryName[,...]] ] [/ec: categoryName[,...] ] [/fa: authorName ] [/ft:className] [/fn: namespace ] [/v: {+|-} ] [/sc: {+|-} ]] [/r ] [/c ]
Parameters
The shared codebase of GUI and console runner means that you can start the GUI runner in combination with any of the flags used by the console runner plus two others covered below.
- /r or /run : Specifies that the GUI runner should run the tests in the AssemblyToTest or ProjectFile as soon as it has loaded without prompt from the user.
- /c or /close : Specified that the GUI runner should close once tests have been run (with /r). Specifying /c without /r will just close the GUI before anything can be done.
Notes
It should be pointed out that /fc, /ec, /fa, /ft, /fn and /v have no effect on how the GUI runs.
Examples
To open the GUI runner and load a test assembly into it
MbUnit.GUI.exe TestAssembly.dll
To open the GUI runner, load a test assembly, run it and generate a HTML report for the tests
MbUnit.GUI.exe TestAssembly.dll /rt:html /r
To open the GUI runner, load a test assembly, run it, generate a HTML report, and close the gui afterwards
MbUnit.GUI.exe TestAssembly.dll /rt:html /r /c
