MbUnit proffers two applications for running tests against your code. The GUI runner discussed on this page and the command-line-based application discussed here. You'll find them both in the MbUnit installation directory; c:\program files\mbunit by default. If you intend to use the console runner a lot, it might not be a bad idea to add its location to your PATH enivronment variable.
At any point while using the console runner you can bring up a summary of this page by typing any of the following alternatives
MbUnit.Cons.exe
MbUnit.Cons.exe /?
MbUnit.Cons.exe /help
MbUnit.Cons.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:{+|-}]]
With the exception of using the /? parameter to bring up the help text, you must always call MbUnit.cons.exe from a directory that contains at least the following three MbUnit dlls
Use full pathnames to locate the assembly containing the tests and the assembly being tested (with the /ap switch) if they are not also in the directory you are calling MbUnit.Cons from.
The MbUnit console runner allows tests in an assembly to be grouped by author and category using the /fc, /ec and /fa flags. See here to learn about specifying test authors and categories.
The /rf, /rnf, /tr and /sr flags do nothing unless /rt is also specified.
The /fc and /ec flags only work with fixture categories as of v2.4. Support is planned to filter by test categories in a future version.
To run tests in two assemblies at once
MbUnit.Cons.exe FirstTestAssembly.dll SecondTestAssembly.dll
To run tests in the current directory against code located in c:\productioncode
MbUnit.Cons.exe TestAssembly.dll /ap:"c:\productioncode"
To run tests and generate a HTML report of the successes and failures of those tests
MbUnit.Cons.exe TestAssembly.dll /rt:html
To run tests and generate a HTML report of the successes and failures of those tests in the current directory
MbUnit.Cons.exe TestAssembly.dll /rt:html /rf:"."
To run tests and generate a HTML report of the successes and failures of those tests in the current directory in a file called MyTestReport.html
MbUnit.Cons.exe TestAssembly.dll /rt:html /rf:"." /rnf:MyTestReport
To run tests and generate a XML report of the successes and failures of those tests with a stylesheet located in the current directory applied to the report post-generation
MbUnit.Cons.exe TestAssembly.dll /rt:xml /tr:ReportTransform.xsl
To run only the test fixtures in TestAssembly.dll tagged with the fixture category "Performance"
MbUnit.Cons.exe TestAssembly.dll /fc:Performance
To run all the test fixtures in TestAssembly.dll which are not tagged with the fixture categories "Performance" or "Exceptions"
MbUnit.Cons.exe TestAssembly.dll /ec:Performance,Exceptions
To run only the test fixtures in TestAssembly.dll tagged as having the author "Andy"
MbUnit.Cons.exe TestAssembly.dll /fa:Andy
To run all the tests in TestAssembly.dll in the class TestAssembly.TestClass
MbUnit.Cons.exe TestAssembly.dll /ft:TestAssembly.TestClass
To run all the tests in TestAssembly.dll in the namespaces TestAssembly.Namespace1 and TestAssembly.Namespace2
MbUnit.Cons.exe TestAssembly.dll /fn:TestAssembly.Namespace1,TestAssembly.Namespace2
To run all the tests in TestAssembly.dll with extra commentary of the tests being run
MbUnit.Cons.exe TestAssembly.dll /v
To run all the tests in TestAssembly.dll within an isolated appDomain
MbUnit.Cons.exe TestAssembly.dll /sc
Once you've compiled your tests and have run them through MbUnit.Cons using a combination of some, all or none of the flags above, you'll see the following standard output on the command line.
>MbUnit.Cons.exe FizzBuzzTests.dll
Parsed arguments:
-- Parsed Arguments
Files:
FizzBuzzTests.dll
Assembly paths:
Report folder:
Report Name Format: mbunit-{0}{1}
Report types:
Show reports: False
Filter Category:
Exclude Category:
Filter Author:
Filter Namespace:
Filter Type:
Verbose: False
ShadowCopyFiles: False
Start time: 17:14
[info] Loading test assemblies
[info] Starting execution
[info] Sorting assemblies by dependencies
[info] Setting up fixture colors
[info] Loading FizzBuzzTests
[info] Found 4 tests
[info] Running fixtures.
[info] Tests finished: 4 tests, 4 success, 0 failures, 0 ignored
[info] All Tests finished: 4 tests, 4 success, 0 failures, 0 ignored in 0.0200288 seconds
[info] MbUnit execution finished in 0.450648s.
The output from the console runner is divided into two parts. The first, headed “Parsed arguments:” reads back to you the options you've set in the call to MbUnit.Cons.exe. In this case, there are none save the name of the test assembly being run, FizzBuzzTests.dll. The second section, headed “Start Time”, shows the progress of the runner as it tries to execute your tests. Note in particular the lines highted in red above, which tell you how many tests were run in total given the options you set - 4 in this case - how many tests were passed, ignored or failed and how long it took to run the tests.