Template:Test case/doc: Difference between revisions

From Path of Exile Wiki
Jump to navigation Jump to search
(Create documentation)
(Moved site-specific documentation to {{PoE test page}})
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
{{mbox
|text=There is a site-specific version of this template, {{tl|PoE test case}}, that makes it as easy as possible to write simple test cases. Please see [[Template:PoE test case/doc|its documentation]] for more details.
}}


{{Lua|Module:Template test case}}
{{Lua|Module:Template test case}}
This template is an easy way to write test cases that examine both the main and sandbox version of a template. It will even show you when the outputs of the main and sandbox version differ, so you can test changes more easily.
This template has lots of uses. See the documentation at [[Wikipedia:Template:Test case/doc]] for all the details.
But here's a sample of how to write a quick set of simple test cases for a PoE Wiki template.
Suppose I want to write a quick testcases page for the {{tl|Update}} template. There are two cases I want to test:
<pre>{{Update|reason=This has all changed in [[version 3.12.0]].|talk=Changes in version 3.12.0}}</pre>
and
<pre>{{Update|section|reason=This section makes no sense}}</pre>
To do that, here's all I need to put on the [[Template:Update/testcases]] page:
<pre>
{{Testcases notice}}
{{Test case|_collapsible=true|_showcode=true|_title=With reason and talk link|reason=This has all changed in [[version 3.12.0]]|talk=Changes in version 3.12.0}}
{{Test case|_collapsible=true|_showcode=true|_title=Section with reason|1=section|reason=This section makes no sense}}
</pre>
* The {{tl|Testcases notice}} template puts a notice at the top of the page giving information about how things work.
* The first {{tl|Test case}} template runs the first test.
** The parameters with names that don't start with an underline are parameters to the template being tested. So in this case, we're passing the parameters <code>|reason=This has all changed in [[version 3.12.0]]|talk=Changes in version 3.12.0</code> to the {{tl|Update}} template.
** The parameters with names that do start with an underline -- <code>_collapsible</code>, <code>_showcode</code>, and <code>_title</code> -- are the parameters that control the behavior of the {{tl|Test case}} template itself. In this case, we're saying "I want you to display the test case in collapsible format. I want it to have the title 'With reason and talk link', and I want it to show the code being tested -- <code><nowiki>{{Update|reason=This has all changed in [[version 3.12.0]]|talk=Changes in version 3.12.0}}</nowiki></code> -- as well as the outputs of the main and sandbox versions of the {{tl|Update}} template when given these parameters."
* The second {{tl|Test case}} template runs the second test.
** The only difference here is that the code that we want to test has an unnamed parameter, <code>|section</code>. We express that in the test case by adding <code>|1=section</code>.
That's it! Now the [[Template:Update/testcases]] page will show these test cases, demonstrating the output from both the main and sandbox versions of the template.


{{Adapted from Wikipedia}}
{{Adapted from Wikipedia}}

Revision as of 01:35, 6 December 2021

This subpage provides documentation for Template:Test case.

There is a site-specific version of this template, {{PoE test case}}, that makes it as easy as possible to write simple test cases. Please see its documentation for more details.

Lua logo

This template uses the following modules:

This template was adapted from Template:Test case/doc on Wikipedia.
Adaptation is noted for reference and attribution only. This template may differ from the original in function or in usage.