Jump to content

Talk:MediaWiki API integration tests

Add topic
From mediawiki.org
Latest comment: 6 years ago by Lucas Werkmeister (WMDE) in topic Extension tests

Extension tests

[edit]

Is there a standard place to put integration tests for extensions? The “Writing tests” section currently only mentions two directories in MediaWiki core. Lucas Werkmeister (WMDE) (talk) 16:48, 18 March 2020 (UTC)Reply

We expect extensions to follow the same format as Core but we will update the documentation with a section for extensions. In the meantime, extensions should be adding the api-testing and mocha npm packages, .api-testing.config.json (for local testing), adding all the tests to tests/api-testing directory of the extension, and adding an api-testing script to package.json.
The changes made in this extension can be used as an example: https://github.com/wikimedia/mediawiki-extensions-EventBus/commit/f19769a0ece90664f3133b8abb086c75c8a97333
Also because of some earlier issues, the CI by default doesn't run the api-testing script on extensions. So extensions would need to also update the CI. Here is an example: https://gerrit.wikimedia.org/r/c/integration/config/+/575316

CAndrew (WMF) (talk) 16:52, 19 March 2020 (UTC)Reply
Great, thanks! Lucas Werkmeister (WMDE) (talk) 17:48, 19 March 2020 (UTC)Reply

Tests depending on wiki configuration

[edit]

Are there any standard patterns for tests that need to set some wiki configuration, or depend on wiki configuration to run? For instance, a test for a feature that’s behind a feature flag and disabled by default. Lucas Werkmeister (WMDE) (talk) 16:50, 18 March 2020 (UTC)Reply

We currently don't have something like that but it could be added as part of the work to disable certain tests depending on extensions: https://phabricator.wikimedia.org/T243977 CAndrew (WMF) (talk) 16:52, 19 March 2020 (UTC)Reply