Template:DW/Test case
More actions
If you're done making changes, please refresh the text.
Please add categories and interwikis to Template:DW/Test case/doc. (View all subpages of this page.)
This template generates a test case for two or more templates. Each template is called with the same parameters, and the test case can be displayed in various different formats.
All parameters passed to this template are passed through to the test-case templates, except for parameters starting with an underscore character ("_"), which are reserved for internal use.
If no templates are specified explicitly, the module uses the base page of the current page as the first template, and its /sandbox subpage as the second template. If only one template is specified explicitly, its /sandbox subpage is used as the second template.
Usage
Basic syntax
{{test case
| [param1] = [value1]
| [param2] = [value2]
| [param3] = [value3]
...
}}
Common syntax
The following options will work with all different test case formats.
{{test case
| _format =
| _output =
| _collapsible =
| _resetRefs =
| _code =
| _showcode =
| _template =
| _template1 =
| _heading1 =
| _template2 =
| _heading2 =
| _template3 =
| _heading3 =
...
| [param1] = [value1]
| [param2] = [value2]
| [param3] = [value3]
...
}}
Some test case formats accept additional parameters as well. See their sections for documentation.
Common parameters
| Parameter | Description |
|---|---|
_format |
The format used to display the test cases. This can be "columns", "rows", "tablerows", "inline" or "default". |
_output |
Allows changes in how the template's output is displayed. The default output is displayed when the _output parameter is not specified or when it is set to any unsupported value. A nowiki version of the template's output is displayed when |_output=nowiki; this is helpful when there are differences in the underlying wikitext which are not visible in the default output. Both the default output and nowiki version are displayed when |_output=nowiki+.
|
_collapsible |
If set to "y" or "yes", the test case is made collapsible. The test case is collapsed and given a green heading if all the template outputs are the same. If any of the template outputs differ, the test case is expanded and given a yellow heading. See #Collapsible test cases for other parameters which only work when _collapsible is enabled. |
_template1, _template2, _template3... |
The names of the templates to be processed. The default of _template1 is the base page of the current page. If _template1 is specified, the default for _template2 is its /sandbox subpage; if not, the default for _template2 is the /sandbox subpage of the base page of the current page. Template names should be entered as you would use them in a normal template invocation, i.e. "2x", not "Template:2x". If you need to test a page in the main namespace you can use a colon prefix, i.e. ":article name". |
_template |
An alias for _template1. If both _template and _template1 are specified, _template will take precedence. |
_showtemplate1, _showtemplate2, _showtemplate3... |
If this is set to "no", then no output is shown for that template. This is useful if you only want to show the main template, or if you only want to show the sandbox template. |
_heading1, _heading2, _heading3... |
Custom headings for each of the templates. |
_showheader |
If this is set to "n" or "no", then no headers are shown. |
_resetRefs |
If set to "y" or "yes", any references generated by the templates tested are reset after each template is expanded. |
_showcode |
Show the template code used to make the test case. If an invocation is specified with the _code parameter, then that is used. Otherwise, an approximation is generated from the arguments. This approximation is not perfect - white space in named arguments is lost, and duplicate arguments are ignored - but it should be fine for template code that is input all on one line without spaces between parameters. |
_code |
Used to specify template code inside <nowiki></nowiki> tags. This is used with the _showcode option to display the template invocation while preserving white space. You must use the magic word "__TEMPLATENAME__" instead of the template name. For example: | _code = <nowiki>{{__TEMPLATENAME__|first|second|foo=bar}}</nowiki>. Note: due to the way nowiki tags work, the template treats the HTML entities <, > and " as if they were the literal characters <, > and " when used with this parameter. |