runModuleUnitTests

This routine is called by the runtime to run module unit tests on startup. The user-supplied unit tester will be called if one has been set, otherwise all unit tests will be run in sequence.

If the extended unittest handler is registered, this function returns the result from that handler directly.

If a legacy boolean returning custom handler is used, false maps to UnitTestResult.fail, and true maps to UnitTestResult.pass. This was the original behavior of the unit testing system.

If no unittest custom handlers are registered, the following algorithm is executed (the behavior can be affected by the --DRT-testmode switch below): 1. Execute any unittests present. For each that fails, print the stack trace and continue. 2. If no unittests were present, set summarize to false, and runMain to true. 3. Otherwise, set summarize to true, and runMain to false.

See the documentation for UnitTestResult for details on how the runtime treats the return value from this function.

If the switch --DRT-testmode is passed to the executable, it can have one of 3 values: 1. "run-main": even if unit tests are run (and all pass), runMain is set to true. 2. "test-or-main": any unit tests present will cause the program to summarize the results and exit regardless of the result. This is the default. 3. "test-only", runMain is set to false, even with no tests present.

This command-line parameter does not affect custom unit test handlers.

extern (C)
runModuleUnitTests
()

Return Value

A UnitTestResult struct indicating the result of running unit tests.

Meta