PHPUNIT(1)

πŸ’… PHPUNIT β€” the phpunit(1) glow-up

okay bestie, welcome to the phpunit command line interface manual, aka the group chat where your PHP tests come to be seen and judged (lovingly) πŸ‘‘. This is a User Commands page for PHPUNIT(1), and we're gonna read it together, no skipping. grab a strawberry drink πŸ“ and let's go.


✨ SYNOPSIS ✨

phpunit [options] <directory|file> ...

that's it. that's the whole vibe. you point it at directories or files, you sprinkle options, it runs your tests. iconic.


πŸ’– DESCRIPTION πŸ’–

this page is lowkey a mega-list of every option, so I'm breaking it down by the cute little groups the original uses: Configuration, Selection, Execution, Reporting, Logging, and Code Coverage. every single flag stays exactly where it was, promise 🫢


🌸 Configuration 🌸

the "set me up before anything runs" section. getting-ready-with-me energy ✨

  • --bootstrap <file> β€” a PHP script that gets included before the tests run. the pre-game ritual.
  • -c, --configuration <file> β€” read your configuration from an XML file.
  • --no-configuration β€” ignore the default configuration file (phpunit.xml). not me ghosting the default config πŸ™ˆ.
  • --extension <class> β€” register a test runner extension with bootstrap <class>.
  • --no-extensions β€” do not register test runner extensions. none. zero. nada.
  • --include-path <path(s)> β€” prepend PHP's include_path with the given path(s).
  • -d <key[=value]> β€” sets a php.ini value.
  • --cache-directory <dir> β€” specify the cache directory.
  • --generate-configuration β€” generate a configuration file with suggested settings.
  • --migrate-configuration β€” migrate your configuration file to the current format.
  • --validate-configuration β€” validate the XML configuration file. vibe check on your config βœ….
  • --generate-baseline <file> β€” generate a baseline for issues.
  • --use-baseline <file> β€” use a baseline to ignore issues.
  • --ignore-baseline β€” do not use a baseline to ignore issues.

πŸ¦‹ Selection πŸ¦‹

which tests actually get to show up to the party πŸ’…

  • --all β€” ignore test selection from the XML configuration file.
  • --list-suites β€” list available test suites.
  • --testsuite <name> β€” only run tests from the specified test suite(s).
  • --exclude-testsuite <name> β€” exclude tests from the specified test suite(s).
  • --list-groups β€” list available test groups.
  • --group <name> β€” only run tests from the specified group(s).
  • --exclude-group <name> β€” exclude tests from the specified group(s).
  • --covers <name> β€” only run tests that intend to cover <name>.
  • --uses <name> β€” only run tests that intend to use <name>.
  • --requires-php-extension <name> β€” only run tests that require PHP extension <name>.
  • --list-test-files β€” list available test files.
  • --list-test-ids β€” list available tests as test IDs.
  • --list-tests β€” list available tests.
  • --list-tests-xml <file> β€” list available tests in XML format.
  • --filter <pattern> β€” filter which tests to run.
  • --exclude-filter <pattern> β€” exclude tests for the specified filter pattern.
  • --test-suffix <suffixes> β€” only search for tests in files with the specified suffix(es). Default: Test.php,.phpt
  • --test-files-file <file> β€” only run test files listed in file (one file by line).
  • --run-test-id <test-id> β€” only run the test identified by the specified test ID.
  • --test-id-filter-file <file> β€” only run tests listed by test ID in file (one test ID per line).

πŸ”₯ Execution πŸ”₯

how the tests actually run. this is where the drama lives 😭

  • --process-isolation β€” run each test in a separate PHP process.
  • --globals-backup β€” backup and restore $GLOBALS for each test.
  • --static-backup β€” backup and restore static properties for each test.
  • --strict-coverage β€” be strict about code coverage metadata.
  • --require-coverage-contribution β€” be strict about tests that do not contribute to code coverage.
  • --strict-global-state β€” be strict about changes to global state.
  • --disallow-test-output β€” be strict about output during tests.
  • --enforce-time-limit β€” enforce time limit based on test size.
  • --default-time-limit <sec> β€” timeout in seconds for tests that have no declared size.
  • --do-not-report-useless-tests β€” do not report tests that do not test anything. leave them alone, they're figuring themselves out 🧚
  • --stop-on-defect[=<n>] β€” stop after the first (or the n-th) error, failure, warning, or risky test.
  • --stop-on-error[=<n>] β€” stop after the first (or the n-th) error.
  • --stop-on-failure[=<n>] β€” stop after the first (or the n-th) failure.
  • --stop-on-warning[=<n>] β€” stop after the first (or the n-th) warning.
  • --stop-on-risky[=<n>] β€” stop after the first (or the n-th) risky test.
  • --stop-on-deprecation[=<n>] β€” stop after the first (or the n-th) test that triggered a deprecation.
  • --stop-on-notice[=<n>] β€” stop after the first (or the n-th) test that triggered a notice.
  • --stop-on-skipped[=<n>] β€” stop after the first (or the n-th) skipped test.
  • --stop-on-incomplete[=<n>] β€” stop after the first (or the n-th) incomplete test.
  • --fail-on-empty-test-suite β€” signal failure using the shell exit code when no tests were run.
  • --fail-on-warning β€” signal failure using the shell exit code when a warning was triggered.
  • --fail-on-risky β€” signal failure using the shell exit code when a test was considered risky.
  • --fail-on-deprecation β€” signal failure using the shell exit code when a deprecation was triggered.
  • --fail-on-phpunit-deprecation β€” signal failure using the shell exit code when a PHPUnit deprecation was triggered.
  • --fail-on-phpunit-notice β€” signal failure using the shell exit code when a PHPUnit notice was triggered.
  • --fail-on-phpunit-warning β€” signal failure using the shell exit code when a PHPUnit warning was triggered.
  • --fail-on-notice β€” signal failure using the shell exit code when a notice was triggered.
  • --fail-on-skipped β€” signal failure using the shell exit code when a test was skipped.
  • --fail-on-incomplete β€” signal failure using the shell exit code when a test was marked incomplete.
  • --fail-on-all-issues β€” signal failure using the shell exit code when an issue is triggered.
  • --do-not-fail-on-empty-test-suite β€” do not signal failure using the shell exit code when no tests were run.
  • --do-not-fail-on-warning β€” do not signal failure using the shell exit code when a warning was triggered.
  • --do-not-fail-on-risky β€” do not signal failure using the shell exit code when a test was considered risky.
  • --do-not-fail-on-deprecation β€” do not signal failure using the shell exit code when a deprecation was triggered.
  • --do-not-fail-on-phpunit-deprecation β€” do not signal failure using the shell exit code when a PHPUnit deprecation was triggered.
  • --do-not-fail-on-phpunit-notice β€” do not signal failure using the shell exit code when a PHPUnit notice was triggered.
  • --do-not-fail-on-phpunit-warning β€” do not signal failure using the shell exit code when a PHPUnit warning was triggered.
  • --do-not-fail-on-notice β€” do not signal failure using the shell exit code when a notice was triggered.
  • --do-not-fail-on-skipped β€” do not signal failure using the shell exit code when a test was skipped.
  • --do-not-fail-on-incomplete β€” do not signal failure using the shell exit code when a test was marked incomplete.
  • --cache-result β€” write test results to the cache file.
  • --do-not-cache-result β€” do not write test results to the cache file.
  • --order-by <order> β€” run tests in order: default|defects|depends|duration-ascending|duration-descending|no-depends|random|reverse|size-ascending|size-descending
  • --resolve-dependencies β€” alias for "--order-by depends".
  • --ignore-dependencies β€” alias for "--order-by no-depends".
  • --random-order β€” alias for "--order-by random".
  • --random-order-seed <N> β€” use the specified random seed when running tests in random order.
  • --reverse-order β€” alias for "--order-by reverse".

🌈 Reporting 🌈

how it tells you what happened. aesthetics matter, periodt πŸ’…

  • --colors=<flag> β€” use colors in output ("never", "auto" or "always").
  • --columns <n> β€” number of columns to use for progress output.
  • --columns max β€” use the maximum number of columns for progress output.
  • --diff-context <n> β€” number of context lines shown around changes in diffs (default: 3).
  • --stderr β€” write to STDERR instead of STDOUT.
  • --no-progress β€” disable output of test execution progress.
  • --no-results β€” disable output of test results.
  • --no-output β€” disable all output.
  • --display-incomplete β€” display details for incomplete tests.
  • --display-skipped β€” display details for skipped tests.
  • --display-deprecations β€” display details for deprecations triggered by tests.
  • --display-phpunit-deprecations β€” display details for PHPUnit deprecations.
  • --display-phpunit-notices β€” display details for PHPUnit notices.
  • --display-errors β€” display details for errors triggered by tests.
  • --display-notices β€” display details for notices triggered by tests.
  • --display-warnings β€” display details for warnings triggered by tests.
  • --display-all-issues β€” display details for all issues that are triggered.
  • --reverse-list β€” print defects in reverse order.
  • --compact β€” replace the default progress and result output with compact format.
  • --teamcity β€” replace the default progress and result output with TeamCity format.
  • --testdox β€” replace the default result output with TestDox format.
  • --testdox-summary β€” repeat TestDox output for tests with errors, failures, or issues.
  • --debug β€” replace the default progress and result output with debugging information.
  • --with-telemetry β€” include telemetry information in debugging information output.

⭐ Logging ⭐

saving the receipts πŸ“

  • --log-junit <file> β€” write test results in JUnit XML format to file.
  • --log-otr <file> β€” write test results in Open Test Reporting XML format to file.
  • --log-teamcity <file> β€” write test results in TeamCity format to file.
  • --testdox-html <file> β€” write test results in TestDox format (HTML) to file.
  • --testdox-text <file> β€” write test results in TestDox format (plain text) to file.
  • --log-events-text <file> β€” stream events as plain text to file.
  • --log-events-verbose-text <file> β€” stream events as plain text with extended information to file.
  • --include-git-information β€” include Git information in supported formats.
  • --no-logging β€” ignore logging configured in the XML configuration file.

πŸŽ€ Code Coverage πŸŽ€

the "how much of my code did the tests actually touch" moment 🫢

  • --coverage-clover <file> β€” write code coverage report in Clover XML format to file.
  • --coverage-openclover <file> β€” write code coverage report in OpenClover XML format to file.
  • --coverage-cobertura <file> β€” write code coverage report in Cobertura XML format to file.
  • --coverage-crap4j <file> β€” write code coverage report in Crap4J XML format to file.
  • --coverage-html <dir> β€” write code coverage report in HTML format to directory.
  • --coverage-php <file> β€” write serialized code coverage data to file.

that's all of part 1 bestie, and there's more coming so don't go anywhere πŸ’–

  • --coverage-text=<file> β€” drops a code coverage report in text format into file, and if you don't say where, it just vibes to standard output 🫢 ([default: standard output])
  • --only-summary-for-coverage-text β€” an option for the text-format coverage report: only show the summary, no scrolling through every file ✨
  • --show-uncovered-for-coverage-text β€” another text-format coverage report option: show the uncovered files too, so you can see exactly which parts ghosted the tests πŸ’€
  • --coverage-xml <dir> β€” writes the code coverage report in XML format into dir πŸŽ€
  • --exclude-source-from-xml-coverage β€” keeps the <source> element out of that XML coverage report, periodt βœ‚οΈ
  • --warm-coverage-cache β€” warms up the static analysis cache πŸ”₯ cozy
  • --coverage-filter <dir> β€” puts <dir> in the coverage reporting zone πŸ’…
  • --branch-coverage β€” reports branch coverage on top of line coverage, both, bestie 🌈
  • --path-coverage β€” reports path coverage on top of line/branch coverage, we're going deeper πŸ¦‹
  • --disable-coverage-ignore β€” turns off the metadata that's used for ignoring code coverage πŸ™ˆ
  • --disable-coverage-targeting β€” turns off the metadata that's used for code coverage targeting 🎯
  • --no-coverage β€” straight-up ignores the code coverage reporting you configured in the XML configuration file, like it never happened πŸ’€

πŸŽ€ Miscellaneous πŸŽ€

the little extras, the odds and ends, the cherry on top πŸ“

  • -h, --help β€” prints this usage information, your lil cheat sheet πŸ‘‘
  • --version β€” prints the version and peaces out ✌️
  • --atleast-version <min> β€” checks that the version is greater than <min> and then exits, quick little sanity check βœ…
  • --check-version β€” checks whether PHPUnit is on the latest version and exits, so you're never out here running dusty code ✨
  • --check-php-configuration β€” checks whether your PHP configuration follows best practices, a whole glow-up checkup 🩺

okay that's genuinely the whole page, bestie, you're officially fluent in phpunit πŸ’œ

this was phpunit version 13.2.6+ds, dated August 2026 β€” iconic, timeless, no cap πŸ‘‘πŸŒˆβœ¨

πŸ“¦ where this page comes from