Difference between revisions of "WikiDB/Unit testing"

From TestWiki
Jump to: navigation, search
(First draft)
(No difference)

Latest revision as of 14:37, 12 April 2019

WikiDB ships with a number of unit tests. These are primarily used during development, to test new features and to help avoid regression bugs. However, you may also wish to run them on your own MediaWiki installation.

Running the unit tests[edit]

Assuming MediaWiki and WikiDB are installed and configured correctly, you can run the unit tests using the standard method that MediaWiki provides for doing this. The tests have been grouped under the label WikiDB, so it is possible to just run the WikiDB tests without running all the other tests for MediaWiki.

There are good instructions on mediawiki.org to guide you through installing the relevant dependencies and running the unit tests.

Here are basic instructions for running the tests. See the above linked-to articles if you need more details:

  1. Navigate to your MediaWiki installation directory
  2. Run the following command: php tests/phpunit/phpunit.php --group WikiDB

Note: If running on Windows you will need to use Windows-style paths (i.e. back-slashes instead of forward-slashes). You will also need to ensure that the PHP executable exists in your path.

This will run just the unit tests for the WikiDB extension.

Note that all WikiDB tests are non-destructive and do not use the local database or file store. Therefore, they are safe to run on a live wiki.

Non-English wikis and other local configuration[edit]

WikiDB has been designed to be fully localisable, and as such will behave differently depending on the wiki's chosen language. There are also a small number of other MediaWiki configuration settings that may affect behaviour of the extension.

The WikiDB unit tests, however, are the one part of WikiDB that has not yet been internationalised. This means that some tests that pass on an English wiki may fail on a non-English wiki.

The long term plan is as follows:

  • Any code that is affected by the wiki language, or any other MediaWiki configuration setting, should have unit test coverage that targets the significant variants in behaviour (for example, alternative number formats).
  • All unit tests should run on the current wiki, regardless of the current configuration settings. In other words, if we have tests to check English number format and French number format, both tests should run on all wikis rather than having the English tests run on English wikis and the French tests on French ones.
  • All unit tests should pass on all supported wiki versions, regardless of configuration.

In the meantime, I encourage bug reports for failing tests, particularly if they are due to internationalisation issues. When reporting test failures, please provide your MediaWiki version, the wiki's content language and the output for the failing tests.