Extension:MWUnit/Test doubles

Sometimes it is difficult to test certain templates because they rely on other templates or components that cannot be used in the test environment. This could be because they will not return the results needed or because executing those templates would have undesirable side effects.

When writing tests, we can replace these templates with Test Doubles, or mock templates. These templates provide the same API as the original template, but their output is controlled via the test.

Usage
The  parser function replaces the given template our mock content.

It is also possible to mock pages in other namespaces:

The content of the mock is only parsed whenever the template is used and can therefore contain template specific syntax. If we want a mock to return the first argument, we can do the following:

Whenever a mocked page is transcluded in a test, the actual content of the page will be ignored and will be replaced with the mocked content.