How can one reliably run unittests

Steven Schveighoffer schveiguy at gmail.com
Wed Aug 25 12:44:54 UTC 2021


On 8/25/21 7:46 AM, jfondren wrote:
> On Wednesday, 25 August 2021 at 11:11:24 UTC, Steven Schveighoffer wrote:
>> The only thing that isn't provided is running individual tests, but 
>> that is a compiler issue (the compiler combines all unittests in a 
>> module into one callable).
> 
> You can run individual tests:

Well, yes. You can do everything yourself (you don't need to use the 
unittest system for this BTW). What I meant to say is, if you want to 
run all unit tests linked into the program, regardless of compile-time 
introspection, you need to rely on the compiler/linker to gather those 
for you (they are all provided as part of the ModuleInfo items), the 
compiler does not store references to individual tests.

The things you *could* do are:

1. Print out messages for each module run, even if they pass
2. Colorize the output of those messages
3. Run unittests of specified modules only.

> I found this out in 
> https://forum.dlang.org/post/bukhjtbxouadyunqwdih@forum.dlang.org , 
> which has a tester that calls tests differently depending on their 
> having a UDA

UDAs are also not provided to the ModuleInfo, so there isn't a way to 
affect the standard unittest framework that way.

-Steve


More information about the Digitalmars-d mailing list