Spec 27.5 states: "Unit tests, when enabled, are run after all static initialization is complete and before the main() function is called. " (https://dlang.org/spec/unittest.html)

main.d:
-------------------
import std.stdio;

shared static this()
{
    import vibe.core.log;
    setLogLevel(LogLevel.trace);

    logDebug("log: statc this");
    WRITELN("WRiteln: static this");
}

void main()
{
    writeln("Edit source/app.d to start your project.");
}

test.d:
-------------------
import std.stdio;

unittest
{
    import vibe.core.log;
    logDebug("log: unittest");
    writeln("writeln: unittest");
}


Running `dub test` will output:
Running ./unit-test-library
writeln: unittest
All unit tests have been run successfully.

Why is the `shared static this()` not executed?

Reply via email to