= Unit testing with Dunit = === A very simple test === All tests in Dunit take place in test fixtures. A test fixture is any class that inherits from TestFixture. The tests are declared in a readable but somewhat abnormal format; TestFixture has a member *tests* with a method opIndexAssign(char[], void delegate()): {{{ #!d module mytests; import dunit.api; class MyTests : TestFixture { this () { tests ["this test always fails"] = { assert (false, "don't worry"); }; } } // This is the test runner, which gets compiled in with your test cases. // You need to have it in one module which imports all the modules in which // you have test cases. mixin (DunitMain); }}} Compiling and running this will result in something like: {{{ Error: mytests.MyTests.this test always fails: AssertError: don't worry }}} We recommend using jive.stacktrace. If you do use jive.stacktrace, you will not see the portion of the stacktrace relating to dunit -- that's automatically filtered out. === Filters === A filter is a wrapper around a test that adds functionality. It must return a void delegate that takes no arguments. There are no limitations on what it takes, as long as it is reasonably clear. For more information, see DunitFilters.