Manual:PHP unit testing/Getting started
|This page is a candidate for deletion. The given reason is: Most of these instructions are outdated and can be consolidated into the page for running the tests KHarlan (WMF) (talk) 18:49, 25 October 2020 (UTC)
This notice should remain for a minimum of 1 week after it was placed on the page. If discussion is still ongoing, it should remain until a consensus is reached, after which the page will either be deleted or this notice removed.
If you disagree with its deletion, please discuss your reasons on this page or on its associated talk page, as applicable.
Administrators: delete this pageLast edit by: KHarlan (WMF) (talk · contribs) · Last edited on: Sun, 25 Oct 2020 18:49:22 +0000
Core MediaWiki PHP unit tests are in the
Extensions often have tests in a
- Install PHPUnit using the MediaWiki PHPUnit installer (Note: only works for Unix-like operating systems, such as Ubuntu, Mac OS X, Linux, etc.)
- Run the tests. The
--testdoxoption produces a nicer output, with checkboxes, where an unchecked box (
[ ]) means the test failed.
php phpunit.php --testdox
- Restricting the tests:
- by file:
php phpunit.php --testdox <path/to/fileTest.php> # Usually it's enough to simply append "Test" to the filename.
- by folder:
php phpunit.php --testdox <path/to/directory/>
- by group:
php phpunit.php --testdox --group <group-name>
- by target:
make help # list available targets
make <target-name> # run the chosen target
- by file:
- In general, the directory structure of
tests/roughly matches that of the code being tested. For instance, the tests for