Manual:PHP unit testing/Running the tests

First run
Make sure you have installed PHPUnit.

Unit tests are run from the command line as there is no graphical user interface as of January 2012. Although phpunit provide a bootstrapping facility, we use a wrapper script. It makes sure the MediaWiki framework is properly initialized using your LocalSettings.php file, then directly call PHPUnit API. Invoking phpunit as is will simply not work.

The wrapper script phpunit.php is located in the tests/phpunit directory and is invoked using the PHP interpreter:

$ cd tests/phpunit $ php phpunit.php

The wrapper script is itself a MediaWiki maintenance script, and will pass all arguments to PHPUnit. To get a list of possible arguments have a look at phpunit --help.

Using default test groups
To make it easier to newcomers, we have a makefile providing some sane default targets. They will run sub groups of tests and are easier to remember than some long shell commands. You will obviously need the make utility. The list of targetsn and their descriptions, is available by running make help.

For instance, to run all tests that have no database impact:

Running an individual test set:

To see the name of each running test, run:

phpunit also provide a kind of checklist that give out a great output for people not familiar with tests or shells: the testdox format: