"But doesn't D have built-in unittest blocks"? Yes, and they're massively useful. Even short scripts can benefit from them with 0 effort and setup. In fact, I use them to test this library. However, for larger projects it lacks some functionality:

    If all tests pass, great. If one fails, it's hard to know why.
The only tool is assert, and you have to write your own assert messages (no assertEqual, assertNull, etc.)
    No possibility to run just one particular test
    Only runs in one thread.


That's exactly the reason I did something like that, too. Especially the first and third reason.

However I use a different approach, which I find easier to handle: I'm using the build-in unittest blocks to register delegates as tests in a central table. These than get executed by a test runner in main().

This way you can register multiple tests using i.e. a loop over sample data or something similar. And it's very easy to implement and has almost no impact on compile time.

Reply via email to