Runs PHPUnit tests with configurable options.
The tests command executes PHPUnit with the resolved configuration.
It supports:
- Running tests in a specific directory
- Generating code coverage reports (HTML, Testdox, Clover, PHP)
- Enforcing minimum coverage thresholds
- Filtering tests by pattern
- Cache management
- Optional progress and coverage-text verbosity control
composer tests
composer tests [path] [options]
composer dev-tools tests -- [path] [options]
vendor/bin/dev-tools tests [path] [options]path(optional)- Path to the tests directory. Default:
./tests.
--bootstrap, -b(optional)- Path to the bootstrap file. Default:
./vendor/autoload.php. --cache-dir(optional)- Path to the PHPUnit cache directory. Default:
.dev-tools/cache/phpunit. --no-cache- Disable PHPUnit caching.
--progress- Enable PHPUnit progress output.
--coverage, -c(optional)- Generate code coverage reports. If a path is provided, reports are saved there. Without a path, reports are saved to the cache directory.
--coverage-summary- When coverage text is generated, show only the summary table.
--filter, -f(optional)- Filter which tests to run based on a pattern (regex supported).
--min-coverage(required)- Minimum line coverage percentage required for a successful run (0-100).
--json- Emit a structured machine-readable payload instead of the normal terminal output.
--pretty-json- Emit the same structured payload with indentation for terminal inspection. This also suppresses PHPUnit progress output automatically so the JSON payload is not polluted by transient progress rendering.
Run all tests:
composer testsRun tests in a specific directory:
composer tests ./tests/unitRun with coverage report:
composer tests --coverage=.dev-tools/coverageRun with concise coverage text output:
composer tests --coverage=.dev-tools/coverage --coverage-summaryRun tests matching a pattern:
composer tests -- --filter=EventTracerTestRun with minimum coverage enforcement:
composer tests --min-coverage=80Run without cache:
composer tests --no-cacheRun with PHPUnit progress output enabled:
composer tests --progress| Code | Meaning |
|---|---|
| 0 | Success. All tests passed and coverage met (if configured). |
| 1 | Failure. Tests failed or coverage below minimum. |
| 2 | Invalid configuration or options. |
- Local
phpunit.xmlis preferred over the packaged default. - Coverage filters are automatically applied to all PSR-4 paths from composer.json.
- Multiple coverage formats are generated: HTML, Testdox HTML, Clover XML, and PHP.
--coverage-summaryforwards PHPUnit's--only-summary-for-coverage-textonly when coverage text output is generated.- progress output is disabled by default.
--jsonand--pretty-jsonkeep progress output disabled so the structured payload stays clean, even when--progressis provided.- The command fails if minimum coverage is not met (when
--min-coverageis set). - The packaged configuration registers the DevTools PHPUnit extension.