Advanced PHPUnit Command-Line Options
Introduction
`--testsuite`:
This flags stimulates test runs for test suite whose name matches the given pattern.
`--group`:
Runs test for only the group specified. A test can be tagged as belonging to a group using the `@group` annotation.
The `@author` and `@ticket` annotations are aliases for `@group` allowing tests to be further filter based on author and ticket.
`--exclude-group`:
This flag excludes groups specified from the test being executed. @group annotation is used to tag a test to a particular group.
`--list-groups`:
Returns a comprehensive list of all the available test groups.
`--test-suffix`:
Prompts a search for test files with specified suffix(es).
`--don’t-report-useless-tests`:
This prevents the return of useless tests.
`--strict-coverage`:
Prompts PHPUnit to be strict about unintentionally covered code.
`strict-global-state`:
Instructs PHPUnit to be strict about global state manipulation.
`--disallow-test-output`:
With this flag, PHPUnit becomes strict with outputs during tests.
`--disallow-todo-tests`
Does not execute tests which have the `@todo` annotation in its doc block.
`--enforce-time-limit`
This enforces time limit based on test size.
`--process-isolation`:
With this flag, each test is executed as a separate PHP process.
`--no-globals-backup`:
This prevents the backup and restore of `$GLOBALS`.
`--static-backup`:
Causes the backup and restore static attributes of user-defined classes.
`--colors`:
This instructs PHPUnit to use colors in outputs and on Windows, to use ANSICON or ConEmu.
This option has three possible values:
`never`: Never displays colors in the output. This is the default value when `--colors` option is not used.
`auto`: Displays colors in the output unless the current terminal doesn’t support colors, or if the output is piped to a command or redirected to a file.
`always`: Displays colors in the output even when the current terminal doesn’t support colors, or when the output is piped to a command or redirected to a file.
NB: When --colors is used without any value, `auto` is the chosen value.
`--columns`
It defines the number of columns to use for progress output. If `max` is defined as value, the number of columns will be maximum of the current terminal.
`--stderr`
It changes the print interface to `STDERR` instead of `STDOUT`.
`--stop-on-error`
This terminates the execution upon first error.
`--stop-on-failure`
Terminates execution upon first error or failure.
`--stop-on-risky`
It stops execution upon first risky test.
`--stop-on-skipped`
It stops execution upon first skipped test.
`--stop-on-incomplete`
It stops execution upon first incomplete test.
`--verbose`
Output more verbose information, for instance the names of tests that were incomplete or have been skipped.
`--debug`
Output debug information such as the name of a test when its execution starts.
`--loader`
Specifies the `PHPUnit\Runner\TestSuiteLoader` implementation to use. The standard test suite loader will look for the source file in the current working directory and in each directory that is specified in PHP’s `include_path` configuration directive. A class name such as `Project_Package_Class` is mapped to the source file name `Project/Package/Class.php`.
`--repeat`
Repeatedly runs the test(s) the specified number of times.
`--testdox`
Reports the test progress in TestDox format.
`--printer`
Specifies the result printer to use. The printer class must extend `PHPUnit\Util\Printer` and implement the `PHPUnit\Framework\TestListener` interface.
`--bootstrap`
A “bootstrap” PHP file that is run before the tests.
`--configuration, -c`
This read configuration from XML file.
If `phpunit.xml` or phpunit.xml.dist` (in that order) exist in the current working directory and` --configuration` is not used, the configuration will be automatically read from that file.
If a directory is specified and if `phpunit.xml` or `phpunit.xml.dist `(in that order) exists in this directory, the configuration will be automatically read from that file.
`--no-configuration`:
Ignore `phpunit.xml` and `phpunit.xml.dist` from the current working directory.
`--include-path`
Prepend PHP’s include_path with given path(s).
`-d`
Sets the value of the given PHP configuration option.
Previous:
Writing Tests for Exceptions and Errors in PHPUnit.
Next:
Test Fixtures in PHPUnit: SetUp and TearDown Explained.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics