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
3—No 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.

Exit Codes in Update Mode (--update) ​

In update mode, exit codes have slightly different semantics:

CodeMeaning
0All updatable assertions rewritten; no non-updatable assertion failures
1Non-updatable assertions (contains, matches, expect) still failing, or --update combined with --dry-run / --stop-on-failure
3No files found or no testable blocks extracted

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.