Skip to content

Exit Codes

DocTest uses standard exit codes compatible with CI systems.

Exit Codes

CodeConstantMeaning
0Command::SUCCESSAll blocks passed (or were skipped)
1Command::FAILUREOne or more blocks failed
3No files found or no testable blocks extracted

CI Usage

Use the exit code to fail CI builds when documentation tests break:

bash
vendor/bin/doctest || exit 1

Or simply:

bash
vendor/bin/doctest

Most CI systems treat any non-zero exit code as a failure.

Verbosity in CI

For CI environments, the default verbosity is usually sufficient. Use -v for more detailed output in logs:

bash
vendor/bin/doctest -v

Combining with Reporters

Use the JSON reporter for machine-readable test results:

Create a doctest.php config:

php
return [
    'reporters' => [
        'console' => true,
        'json'    => 'build/doctest.json',
    ],
];

Released under the MIT License.