How can one reliably run unittests

jfondren julian.fondren at gmail.com
Mon Sep 6 16:52:38 UTC 2021


On Monday, 6 September 2021 at 16:35:03 UTC, Walter Bright wrote:
> On 9/5/2021 3:00 PM, deadalnix wrote:
>> On Sunday, 5 September 2021 at 21:00:15 UTC, Walter Bright 
>> wrote:
>>> The unittest feature doesn't do any of those things unless 
>>> you code it to.
>> 
>> It already output a very similar message: "15 modules passed 
>> unittests"
>
> That must be a fairly recent change I wasn't aware of.

It came in with https://github.com/dlang/druntime/pull/1685 , 
which also added a lot more control over how the tests could be 
run.

Old behavior: adding -unittest causes unittest functions to be 
compiled in and to run before main, and that's it: the program 
only exited before main on error because that's how assert() 
failures are handled, and the program continued to run if there 
were no errors. This perfectly fits the use case of "I want a 
build of my program with a bunch of extra testing, ala a debug or 
a non-release build" but required some workarounds to fit the use 
case of "I want to run all of my unittests, *only*"

Much of this thread can be listed under complaints about a third 
use case, "I want to run a single module's tests, *only*"


More information about the Digitalmars-d mailing list