LinuxCommandLibrary
GitHub F-Droid Google Play Store

phpunit

PHP testing framework

TLDR

Run all tests
$ phpunit
copy
Run specific test file
$ phpunit [tests/ExampleTest.php]
copy
Run tests in directory
$ phpunit [tests/]
copy
Run specific test
$ phpunit --filter [testMethodName]
copy
Generate coverage report
$ phpunit --coverage-html [coverage/]
copy
Use configuration
$ phpunit -c [phpunit.xml]
copy

SYNOPSIS

phpunit [options] [files...]

DESCRIPTION

phpunit is the de facto unit and integration testing framework for PHP, based on the xUnit family. It discovers and runs test classes that extend `PHPUnit\Framework\TestCase`, providing rich assertions, data providers, test doubles, and code coverage reporting.Tests are typically organized under a `tests/` directory and configured via a `phpunit.xml` file at the project root, which defines test suites, bootstrap files, and coverage filters. Results can be output in TestDox, JUnit XML, and other formats for CI integration.

PARAMETERS

FILES

Test files or directories.
--filter PATTERN
Filter tests.
--coverage-html DIR
HTML coverage report.
-c FILE
Configuration file.
--testdox
TestDox output.
--help
Display help.

CONFIGURATION

phpunit.xml, phpunit.xml.dist

Project configuration: test suites, bootstrap, coverage filters, and PHP settings.

CAVEATS

Configuration via phpunit.xml. Code coverage requires Xdebug or PCOV to be installed. Major versions (9, 10, 11) have removed deprecated APIs, so test code may need updates when upgrading.

HISTORY

PHPUnit was created by Sebastian Bergmann as the standard PHP testing framework.

SEE ALSO

phpspec(1), pest(1), php(1)

Copied to clipboard
Kai

AltStyle によって変換されたページ (->オリジナル) /