What's new:

Built-in unittest blocks can now have a name with just a string UDA:

@("test that does stuff") unittest {... }

Why is this important? If you just want to run unit tests in threads and have them named, you don't need to import unit_threaded in your source code anymore. I'm going to build on this later with a tool to make it so that existing codebases can benefit from unit_threaded without using it directly.

Value-parametrized tests

Have you ever written a test that looks like this?

unittest {
    foreach(v; [...]) {
        //test code

I have, and when it fails you have no idea which of the values caused the failure. Now, you can do this:

@(42, 2, 3)
void testValues(int i) {
    (i % 2 == 0).shouldBeTrue;

testValues will be run once for each value UDA with the same type in its declaration (in this case, int). Each run will be considered a different test and reported as such with the value that was used. In the above case, the output will contain this:

    tests/pass/attributes.d:76 - Expected: true
    tests/pass/attributes.d:76 -      Got: false

Test tests.pass.attributes.testValues.3 failed.



Reply via email to