< Extension:MWUnit

The MWUnit command-line test runner is a maintenance script located in MWUnit/maintenance/runTests.php 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 foobar. For each test, the script will print a single character to indicate progress:

.
Printed when a test succeeds.
R
Printed when a test has been marked as risky.
S
Printed when a test has been skipped.
F
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-pages|--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
    --covers (-c): Only run tests that cover the specified template
        (without namespace)
    --group (-g): Only run tests from the specified group
    --list-groups: List available test groups
    --list-pages: List available test pages
    --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
    --page (-p): Filter which test page to run
    --version: Prints the version
--columns <n>
Defines the number of columns used for progress output when using the default result printer.
--covers|-c <template>
Only runs the tests that cover the specified template.
--group|-g <group>
Only runs the tests from the specified group.
--list-groups
Lists all available test groups.
--list-pages
Lists all available test pages.
--list-tests
Lists all available tests.
--no-progress
Do not report test progress.
--test|-t <test>
Only runs the specified test.
--page|-p <testsuite>
Only run tests from the specified page (should not include namespace).
--testdox|-d
Outputs the test progress to the console as agile documentation instead (TestDox format):
extensions:~/MWUnit$ php maintenance/runTests.php --group "foobar" -d
MWUnit 2.0.0 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.

This article is issued from Mediawiki. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.