Console test runner
The default test runner with Dunit, which will run if you use mixin(DunitMain), is the console runner. By default, it will print out one line per test, with the fully qualified name and whether the test failed. It will also include any exception and stack trace associated with the test. Being a replacement for your application's main() function, it takes command-line arguments.
How do I run tests?
Assuming you have a module such as this:
module mytests.main; import dunit.api; import mytests.testModule1; import mytests.testModule2; // and import the rest of the modules containing tests... mixin (DunitMain);
You simply compile that (using, for instance, DSSS), and run the resulting executable.
I hope to create a tool that can scan a directory structure and output a dunit main module, but that does not currently exist.
Which tests do I have? I can't remember!
./mytests --list ./mytests -l
This will display a list of all tests you have, one per line, with fully qualified names.
I have too many tests. How do I just run a few of them?
./mytests --filter "regular expression" ./mytests -f "regular expression"
The filter option takes an argument that is interpreted as a Tango regular expression. Any test whose fully qualified name matches that expression will be run.
You can specify the filter option multiple times; if you do, then a test must pass at least one of the filters.
I don't want to see anything except failed tests. How do I do that?
./mytests --quiet ./mytests -q
For any test that succeeds, there will be no output. If a test fails, you will get the same output as normal.
I'm running my tests on a continuous integration server that expects junit-style XML.
./mytests --xml ./mytests -x
Using the XML option invalidates all other options. (There isn't much use case for it, after all.)
Your documentation is wrong.
Sorry about that. You can try the help option instead:
./mytests --help ./mytests -h
A note on argument parsing
For Dunit, "-x" is the same as "--x" and "/x". So you can run your tests with "./mytests /q" or "./mytests /quiet" or "./mytests -q", and so on.
However, you cannot join any short arguments together. "-q -p" shows progress but no success messages; "-qp" is ignored.