Code: ------- import std.stdio; unittest { writeln("x"); } unittest { writeln("y"); } unittest { writeln("z"); } ------- Compiler invocation: ------- dmd -unittest -main -run test.d ------- Output: ------- x y z 1 unittests passed ------- Clearly, all 3 unittests ran; yet the default test runner reports only 1 unittest. This is misleading, and gives the wrong impression that some unittests were not run. Expected output: -------- x y z 3 unittests passed --------
The message is wrong, it shows how many modules were tested, not the number of unittests. That number is probably not available in the current implementation which relies on ModuleInfo, see https://github.com/dlang/druntime/blob/435ae8a21034ef50fa4769e3aaba5778dbc76557/src/core/runtime.d#L602-L617
@quickfur created dlang/druntime pull request #3129 "Fix issue 20910: fix misleading unittest runner messages." mentioning this issue: - Issue 20910: fix misleading unittest runner messages. The number returned by runModuleUnitTests is not the number of tests, but the number of modules tested. https://github.com/dlang/druntime/pull/3129
dlang/druntime pull request #3129 "Fix issue 20910: fix misleading unittest runner messages." was merged into master: - 209ce9b0c18ba27519f900ca31947ee3bf1e0f15 by H. S. Teoh: Fix issue 20910: fix misleading unittest runner messages. The number returned by runModuleUnitTests is not the number of tests, but the number of modules tested. https://github.com/dlang/druntime/pull/3129