October 19, 2020
https://issues.dlang.org/show_bug.cgi?id=21330

          Issue ID: 21330
           Summary: __traits(getUnitTests) on a module should include
                    unittests from anonymous mixins
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: maxsamukha@gmail.com

mixin template Test() {
    unittest {
    }

    void foo() {
    }
}
mixin Test;

pragma(msg, __traits(allMembers, onlineapp)); // tuple("object", "Test", "foo",
"main")
pragma(msg, __traits(getUnitTests, onlineapp)); // tuple()

void main() {
}

If allMembers returns "foo", then it is reasonable to expect that getUnitTests should return the unittest. Actually, it it impossible to get to the unittest at all because it is impossible to refer to anonymous mixins explicitly.

--