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. Run all unit tests, tracking tests executed and passes. For each that fails, print the stack trace, and continue. 2. If there are no failures, set the summarize flag to false, and the runMain flag to true. 3. If there are failures, set the summarize flag to true, and the runMain flag 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), main is still run. This is currently the default. 2. "test-or-main": any unit tests present will cause the program to summarize the results and exit regardless of the result. This will be the default in 2.080. 3. "test-only", the runtime will always summarize and never run main, even if no tests are 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.

Suggestion Box / Bug Report