Template:Test case/doc

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, with the exception of parameters starting with an underscore character, which are reserved for internal use.

Basic syntax
If no templates are explicitly specified, the module uses the root page of the current page as the first template, and its /sandbox subpage as the second template.  If only one template is explicitly specified, its /sandbox subpage is used as the second template.

Common syntax
The following options will work with all different test case formats. 

Some test case formats accept additional parameters as well. See their sections for documentation.

Default format
This format is used when _format is not specified, or when it's set to default. It is not impacted by any extra parameters.

Columnar format
Set columns to arrange the test cases side-by-side in a table. This is especially useful for comparing long and thin templates, such as infoboxes. It is impacted by the following extra parameters:

Rows and tablerows formats
Setting rows or tablerows arranges the test case outputs in a vertical line, one above another, in a table. These two formats differ primarily in the placement of the headings: rows puts them above the table, whereas tablerows has them to the left of the table. They are impacted by the following extra parameters:

Inline format
Set inline for test cases that can be displayed entirely on a single line. If used with templates that display over multiple lines, it may produce unexpected results. This format creates a bulleted list by placing  before each line of output. It is impacted by the following extra parameters:

Examples

 * Using

Default:

With yes:


 * Using

With # and _addline:

Output
The _output parameter allows changes in how the template's output is displayed. It should work with any of the test case formats; the following examples use tablerows.

Default output
The default output is displayed when the _output parameter is not specified, or when it is set to any unsupported value; this example uses default.

Nowiki output
A nowiki version of the template's output is displayed when nowiki. This is helpful if there are differences in the underlying wikitext which are not visible in the default output.

Nowiki+ output
Both the default output and nowiki version are displayed when nowiki+.

Collapsible test cases
If 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. It has the following extra parameters:

With yes
This is useful for templates with a small number of parameters. It displays the template code in the title, eliminating the need for both _title and yes. For actual tests implemented with yes, see Template:URL/testcases.

With yes
If yes, the test case will always be expanded upon loading the page. This setting overrides the default functionality in which the test case is collapsed unless two or more outputs do not match. The following example would normally be collapsed, as indicated by green background of title:

With no
If no, the test case will always be collapsed upon loading the page. This setting overrides the default functionality in which the test case is collapsed unless two or more outputs do not match. The following would normally be expanded, as indicated by yellow background of title:

Usage


Usage


Usage


Technical limitations
The template has the following known technical limitations:
 * An error will be generated if processing the entire page takes more than 10 seconds. This is an intentional limit in the Scribunto extension that runs Module:Template test case, on which this template is based. If a test cases page takes more than 10 seconds to load, you may need to split it up into different pages.
 * When generating the template code used with _showcode, whitespace in named parameters is ignored, numbered parameters like 1 may be incorrectly displayed as positional parameters, and duplicate parameters are ignored. This is due to how template parameters are processed before they are passed to Module:Template test case.
 * When using a template invocation inside nowiki tags with the _code parameter, the HTML entities &amp;lt;, &amp;gt; and &amp;quot; are converted to the literal characters &lt;, &gt; and &quot;. This is due to the way nowiki tags work.
 * For collapsible test cases, all text inside each extension tag (e.g., , or ) is treated as equal. These tags are converted to strip markers before they are passed to the template, and all strip markers include a unique hexadecimal string. Even if strip markers were unstripped before being compared, the same wikitext would not be guaranteed to result in exactly the same unstripped code. So this module ignores the content of strip markers for the purposes of testing equality. This has the unwanted side effect that e.g. all  tags are treated as though they are equal, but should be adequate for most uses.