Extension:MWUnit/Organizing tests

MWUnit supports several ways to group and organize tests. This page explains how to appropriately organize tests.

An important property of MWUnit is that tests are reasonably composable. You are able to run any number of tangential tests together. For instance, all tests in a group, or all tests on a test page, all tests covering a template, or an individual test.

Composing a group
Any test must belong to a group. A test can be added to a specific group using the  annotation, as shown in this example:

 ...

Not having this annotation will result in an error.

Tests in the same group can be run together, but are not necessarily in the same fixture. This means that tests in the same group may not necessarily share the same global state and parser. Only tests that are on the same page will share the same fixture.

Tests in the same group can be run together via the special page.

It is good practice to group tests together that test a certain feature of your wiki. If you have a set of templates that are only used to render the Main Page, it is good to put all tests covering these templates in one group.

Organizing tests on a test page
A test page is any page in the  namespace. It can contain one or many tests. Each test on a test page shares the same parser and global state. A single test page should preferably test one, and only one, template (or some other "unit" of wikitext, such as a parser function).

Tests on the same test page can be run in a group only via the test page itself. It can be done by pressing the "Run unit tests" button in the side menu or by pressing the "Run tests" button at the top of the page.