3. Configuration
PHPUnit builds the effective configuration for a test suite run by combining three layers:
Built-in defaults that PHPUnit ships with.
XML configuration loaded from
phpunit.xml(or the file passed to--configuration), applied on top of the defaults.CLI options passed on the command line, applied on top of the XML configuration.
Each layer overrides the previous one for the settings it touches. Settings that a layer does not specify are inherited from the layer below. For example, beStrictAboutCoverageMetadata defaults to false; setting beStrictAboutCoverageMetadata="true" in phpunit.xml turns it on for all runs; passing --strict-coverage turns it on for a single run even when the XML does not enable it.
The tables in this appendix cross-reference the CLI options (see CLI Options) and the XML configuration attributes and elements (see XML Configuration File) that participate in this override model, along with their built-in defaults. Options that do not participate (CLI-only or XML-only) are listed at the end.
Configuration
CLI option |
XML setting |
Default |
|---|---|---|
|
bootstrap attribute on |
— |
|
cacheDirectory attribute on |
— |
|
cacheResult attribute on |
|
|
<bootstrap> under |
(additive) |
|
<includePath> under |
(additive) |
|
<ini> under |
(additive) |
|
baseline attribute on |
— |
Selection
CLI option |
XML setting |
Default |
|---|---|---|
|
defaultTestSuite attribute on |
— |
|
<group> under |
— |
|
<group> under |
— |
Execution
CLI option |
XML setting |
Default |
|---|---|---|
|
processIsolation attribute on |
|
|
backupGlobals attribute on |
|
|
backupStaticProperties attribute on |
|
|
beStrictAboutCoverageMetadata attribute on |
|
|
beStrictAboutChangesToGlobalState attribute on |
|
|
beStrictAboutOutputDuringTests attribute on |
|
|
beStrictAboutTestsThatDoNotTestAnything attribute on |
|
|
enforceTimeLimit attribute on |
|
|
defaultTimeLimit attribute on |
|
|
executionOrder attribute on |
|
|
executionOrder |
|
|
executionOrder |
|
|
resolveDependencies attribute on |
|
Stopping on Issues
CLI option |
XML setting |
Default |
|---|---|---|
|
stopOnDefect attribute on |
|
|
stopOnError attribute on |
|
|
stopOnFailure attribute on |
|
|
stopOnWarning attribute on |
|
|
stopOnRisky attribute on |
|
|
stopOnDeprecation attribute on |
|
|
stopOnNotice attribute on |
|
|
stopOnSkipped attribute on |
|
|
stopOnIncomplete attribute on |
|
Failing on Issues
CLI option |
XML setting |
Default |
|---|---|---|
|
failOnAllIssues attribute on |
|
|
failOnEmptyTestSuite attribute on |
|
|
failOnWarning attribute on |
|
|
failOnRisky attribute on |
|
|
failOnDeprecation attribute on |
|
|
failOnPhpunitDeprecation attribute on |
|
|
failOnPhpunitNotice attribute on |
|
|
|
|
|
failOnNotice attribute on |
|
|
failOnSkipped attribute on |
|
|
failOnIncomplete attribute on |
|
Reporting
CLI option |
XML setting |
Default |
|---|---|---|
|
colors attribute on |
|
|
columns attribute on |
|
|
stderr attribute on |
|
|
reverseDefectList attribute on |
|
|
testdox attribute on |
|
|
testdoxSummary attribute on |
|
|
displayDetailsOnAllIssues attribute on |
|
|
displayDetailsOnIncompleteTests attribute on |
|
|
displayDetailsOnSkippedTests attribute on |
|
|
displayDetailsOnTestsThatTriggerDeprecations attribute on |
|
|
displayDetailsOnPhpunitDeprecations attribute on |
|
|
displayDetailsOnPhpunitNotices attribute on |
|
|
displayDetailsOnTestsThatTriggerErrors attribute on |
|
|
displayDetailsOnTestsThatTriggerNotices attribute on |
|
|
displayDetailsOnTestsThatTriggerWarnings attribute on |
|
Logging
CLI option |
XML setting |
Default |
|---|---|---|
|
<junit outputFile> under |
— |
|
|
— |
|
|
|
|
<teamcity outputFile> under |
— |
|
<testdoxHtml outputFile> under |
— |
|
<testdoxText outputFile> under |
— |
Code Coverage
CLI option |
XML setting |
Default |
|---|---|---|
|
pathCoverage attribute on |
|
|
disableCodeCoverageIgnore attribute on |
|
|
<clover outputFile> under |
— |
|
|
— |
|
<cobertura outputFile> under |
— |
|
<crap4j outputFile> under |
— |
|
<html outputDirectory> under |
— |
|
<php outputFile> under |
— |
|
<text outputFile> under |
— |
|
|
|
|
|
|
|
<xml outputDirectory> under |
— |
|
|
|
CLI-only Options
The following CLI options have no XML counterpart. They either control the current invocation of the test runner, perform one-shot operations, or suppress parts of the XML configuration.
Configuration selection and one-shot operations:
-c,--configuration <file>--no-configuration--no-extensions--no-coverage--no-logging--generate-configuration--migrate-configuration--generate-baseline <file>--ignore-baseline--warm-coverage-cache
Test selection and filtering:
--all--testsuite <name>(also overrides the XMLdefaultTestSuiteattribute; see above)--exclude-testsuite <name>--filter <pattern>--exclude-filter <pattern>--covers <name>--uses <name>--requires-php-extension <name>--test-suffix <suffix>
Introspection:
--list-suites--list-groups--list-tests--list-test-files--list-tests-xml <file>
Alternative output and event streaming:
--debug--with-telemetry--teamcity--log-events-text <file>--log-events-verbose-text <file>--no-output--no-progress--no-results
Code coverage:
--coverage-filter <dir>
Miscellaneous:
--random-order-seed <N>-h,--help--version--atleast-version <min>--check-version--check-php-configuration
XML-only Settings
The following XML configuration settings have no CLI counterpart and can only be changed by editing the configuration file.
On the <phpunit> element:
controlGarbageCollector (default:
false)numberOfTestsBeforeGarbageCollection (default:
100)requireCoverageMetadata (default:
false)timeoutForSmallTests (default:
1)timeoutForMediumTests (default:
10)timeoutForLargeTests (default:
60)
Test suite definition:
The <testsuites> element and its children
Source code configuration:
The <source> element and all of its attributes and children
Code coverage:
includeUncoveredFiles attribute on
<coverage>(default:true)ignoreDeprecatedCodeUnits attribute on
<coverage>(default:false)<html> color and bound attributes (
lowUpperBound,highLowerBound,colorSuccessLow,colorSuccessMedium,colorSuccessHigh,colorWarning,colorDanger,customCssFile)thresholdattribute on<coverage><report><crap4j>(default:50)
PHP environment:
<const> under
<php><var> under
<php><env> under
<php><get> under
<php><post> under
<php><cookie> under
<php><server> under
<php><files> under
<php><request> under
<php>
Extensions:
<parameter> elements under
<extensions><bootstrap>