Extension:MWUnit/Configuring MWUnit

From mediawiki.org
Jump to navigation Jump to search

MWUnit's default behaviour can be changed through several configuration parameters.

Configuration parameters[edit]

$wgMWUnitMaxTestExecutionTime[edit]


This configuration parameter defines the maximum execution time for all tests in a test run. It corresponds directly with the PHP function set_time_limit(). This function limits the maximum execution time of a PHP script. The limit defined by this configuration parameter is therefore a hard limit and the script will die dramatically when this time limit is reached.

$wgMWUnitDefaultTestDox[edit]


This configuration parameter defines whether or not to use TestDox as the default result printer when running MWUnit through the command-line test runner.

$wgMWUnitBackupGlobals[edit]


This configuration parameter defines whether or not to back up PHP superglobals before each test case and restore them after each test.

When this configuration parameter is set to true, MWUnit will clone all superglobals, with $_SESSION as the only exception, and store these before running a test. After the test has completed, MWUnit will restore the superglobals to the superglobals it saved before the test.

$wgMWUnitStrictCoverage[edit]


This configuration parameter defines whether or not to be strict about untruthful @covers annotations. When this configuration parameter is set to true, MWUnit will perform additional checks to make sure the template given in the @covers annotation is actually used in the test case. If the template in the test case is not used in the test, the test will be marked as risky.

These checks are performed by hooking into the ParserFetchTemplate hook and checking if that hook is ever fired during the test case with the template specified in the annotation. Since the MediaWiki parser caches template fetches, this hook is only ever called once per template. This would mean if we created a variable (through the Variables extension)in the fixture with that template, the hook would not get called in the test case. To remedy this, the initial parser before the first test case is cloned and stored. Before the test is run, we check if the template specified in the @covers annotation is in the initial parser's cache and presume it is used if it is. This may rarely lead to false negatives, unfortunately.

Individual tests can be exempt from these checks by annotating them with @ignoreStrictCoverage.

$wgMWUnitForceCoversAnnotation[edit]


This configuration parameters defines whether or not to force tests to have a @covers annotation. Tests without the @covers annotation will not be executed when this check is enabled.

$wgMWUnitAllowRunningTestAsOtherUser[edit]


This configuration parameter defines whether or not to allow users with the right mwunit-mock-user to actually run a test as a different user.

$wgMWUnitShowProfilingInfo[edit]


This configuration parameter defines whether or not to show profiling info on the result special page. If this parameter is set to true, profiling information, such as running time and memory usage will be shown on the special page. Profiling information will be collected regardless of the value of this parameter.

$wgMWUnitAllowTransclusion[edit]


This configuration parameter defines whether or not to allow the transclusion of pages in the NS_TEST namespace.

$wgMWUnitMaxTestCases[edit]


This configuration parameter defined the maximum number of test cases on a single test page.

$wgMWUnitMaxReportedErrors[edit]


This configuration parameter defined the maximum number of errors reported for a single test page.