Extension:MWUnit/Running tests

This page details how to run tests.

Running tests on the wiki
There are several ways to run the tests that you have written. The most obvious way is via the test page itself. In the sidebar there should be a button under "Unit testing" labelled "Run unit tests". This button will run all tests on the current test page, regardless of which group they are in.

Another way to run tests is through the special page. The special page can run all tests in the given group or a single test case.

The  user right is required for running tests.

The command-line test runner
The MWUnit command-line test runner is a maintenance script located in  and can be invoked through the following command:

$ php runTests.php

The following code shows how to run a group of tests with the MWUnit command-line test runner:

extensions:~/MWUnit$ php maintenance/runTests.php --group "foobar" MWUnit 0.6 by Marijn van Wezel and contributors.

...

OK (3 tests, 3 assertions)

When invoked as shown above, MWUnit will run all tests in the group. For each test, the script will print a single character to indicate progress:


 * : Printed when a test succeeds.
 * : Printed when a test has been marked as risky.
 * : Printed when an assertion failed when running the test.

Command-line options
We open up the command-line help menu in the following code:

extensions:~/MWUnit$ php maintenance/runTests.php --help

Command-line test runner for MWUnit.

Usage: php runTests.php [--columns|--conf|--dbgroupdefault|--dbpass|--dbuser|--globals|--group|--help|--list-groups|--list-suites|--list-tests|--memory-limit|--mwdebug|--no-progress|--profiler|--quiet|--server|--test|--testdox|--testsuite|--version|--wiki]

Generic maintenance parameters: --help (-h): Display this help message --quiet (-q): Whether to suppress non-error output --conf: Location of LocalSettings.php, if not default --wiki: For specifying the wiki ID   --globals: Output globals at the end of processing for debugging --memory-limit: Set a specific memory limit for the script, "max" for no limit or "default" to avoid changing it   --server: The protocol and server name to use in URLs, e.g.        http://en.wikipedia.org. This is sometimes necessary because server name detection may fail in command line scripts. --profiler: Profiler output format (usually "text") --mwdebug: Enable built-in MediaWiki development settings

Script dependant parameters: --dbuser: The DB user to use for this script --dbpass: The password to use for this script --dbgroupdefault: The default DB group to use.

Script specific parameters: --columns: Number of columns to use for progress output --group (-g): Only run tests from the specified group --list-groups: List available test groups --list-suites: List available test suites --list-tests: List available tests --no-progress: Do not display progress --test (-t): Only run the specified test --testdox (-d): Report test execution progress in TestDox format --testsuite (-s): Filter which testsuite to run --version: Prints the version


 * : Defines the number of columns used for progress output when using the default result printer.


 * : Only runs the test from the specified group.


 * : Lists all available test groups.


 * : Lists all available test suites.


 * : Lists all available tests.


 * : Do not report test progress.


 * : Only runs the specified test.


 * : Only run tests from the specified page (should not include namespace).


 * : Outputs the test progress to the console as agile documentation instead (TestDox format):

extensions:~/MWUnit$ php maintenance/runTests.php --group "foobar" -d MWUnit 0.6.1 by Marijn van Wezel and contributors.

IncreaseExponentially ✔ Is Initially Zero ✔ Grows Exponentially

OK (2 tests, 34 assertions)

You can read more about the generic maintenance parameters on the corresponding Manual page.