Template:Test case/doc

From Path of Exile Wiki
Revision as of 20:27, 5 December 2021 by KickahaOta (talk | contribs) (Create documentation)
Jump to navigation Jump to search

This subpage provides documentation for Template:Test case.

Lua logo

This template uses the following modules:

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 {{Update}} template. There are two cases I want to test:

{{Update|reason=This has all changed in [[version 3.12.0]].|talk=Changes in version 3.12.0}}

and

{{Update|section|reason=This section makes no sense}}

To do that, here's all I need to put on the Template:Update/testcases page:

{{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}}
  • The {{Testcases notice}} template puts a notice at the top of the page giving information about how things work.
  • The first {{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 |reason=This has all changed in version 3.12.0|talk=Changes in version 3.12.0 to the {{Update}} template.
    • The parameters with names that do start with an underline -- _collapsible, _showcode, and _title -- are the parameters that control the behavior of the {{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 -- {{Update|reason=This has all changed in [[version 3.12.0]]|talk=Changes in version 3.12.0}} -- as well as the outputs of the main and sandbox versions of the {{Update}} template when given these parameters."
  • The second {{Test case}} template runs the second test.
    • The only difference here is that the code that we want to test has an unnamed parameter, |section. We express that in the test case by adding |1=section.

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.



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.