*** Welcome to piglix ***

Wikipedia:TESTCASES


Templates are a very powerful feature of the software used for , but mistakes can be easily made, even by experienced users. Complex templates should therefore be accompanied by sandboxes and test cases to prevent bugs. Temporary sandboxes - or the may be useful places to try new experiments or for users new to template development.

Most protected templates already have a sandbox subpage and testcases subpage. The names of these pages are default. At the bottom of each template's page are links to create\edit the template's sandbox and testcases pages.

For example, here are the subpages for {{}}:

It is highly recommended to apply the test case pattern to templates using that can generate very different looking output, such as ones that take many parameters, or the ones that have many branches of the #switch operator.

For navigational boxes with mostly identical results on each transcluding page, the benefit may not outweigh the time and effort to create a sandbox page, but if in doubt, sandbox it. Any template that is marked as a High-risk Template should always be tested before an edit is made. With other pages, you should still check which pages use the template (via the "What Links Here" link in the Tools section of the linkbar at the left side of the screen).

To make a change to a template which already has /sandbox and /testcases subpages, the process is similar to the above.

On the /testcases page, there should be one test case for each different behaviour of your template. For example, if your template outputs a banner message, and if the parameter |italic=yes makes that message italicized, you should add one test case for the normal message and one for the italicized message. If that template has another parameter, |date=, where the user inserts the date, then there should be a third test case for that. You should try and be thorough and make cases for all the ways users might use your template; however, it is often impractical to add test cases for every single parameter combination, so you should choose the most relevant ones wisely.

Manually formatting gives you a great deal of flexibility, but care must be taken to ensure that all the template parameters are entered correctly. An error in one of the test cases is often harder to find than an error in the template itself.

This format works well for banner templates and for lengthy text, e.g. citations. Note that you can format these kinds of test automatically using and other similar templates.


...
Wikipedia

...