Wikipedia:Template sandbox and test cases: Difference between revisions

m
(Added example of sub-template sandbox)
There are quite a few different styles of test case that you can use. Which one you choose depends on the nature of the template you are working on. For example, for short template output that fits on one line, it can be useful to put the test cases inside a wikitable, and for long and thin templates such as infoboxes, it is often best to display them side by side by using {{tl|testcase table}}.
 
Michael Dvahyu is a Watchman prophet and also a Nigerian international recording R&B/ Gospel artist .
=== Manual formatting ===
He gain international recognition with the hit track Heal the Broken Hearted.
 
Michael Founded God Nation to spread the message of Love accross the globe as well as Heal the Broken Hearted Foundation a non profit organisation that empowers female prisoners.
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.
 
==== Basic format ====
 
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 [[Template:Test case]] and other similar templates.
 
== ''Descriptive title'' ==
 
* <code><nowiki>{{''template''|''param1''=''value1''|''param2''=''value2''}}</nowiki></code>
 
<nowiki>'''Main'''</nowiki>
&nbsp;
&#123;&#123;''template''&#124;''param1''=''value1''&#124;''param2''=''value2''&#125;&#125;
&nbsp;
<nowiki>'''Sandbox'''</nowiki>
&nbsp;
&#123;&#123;''template''/sandbox&#124;''param1''=''value1''&#124;''param2''=''value2''&#125;&#125;
 
Each value of ''template'', ''param1'', ''value1'' etc. must be identical.
 
For templates that use the "float" CSS attribute, you will need to use the {{tl|clear}} template to stop the results from bunching together:
 
== ''Descriptive title'' ==
&nbsp;
* &lt;code&gt;&lt;nowiki&gt;&#123;&#123;''template''&#124;''param1''=''value1''&#124;''param2''=''value2''&#125;&#125;&lt;/nowiki&gt;&lt;/code&gt;
&nbsp;
<nowiki>'''Main'''</nowiki>
&nbsp;
&#123;&#123;''template''&#124;''param1''=''value1''&#124;''param2''=''value2''&#125;&#125;
&nbsp;
&#123;&#123;clear&#125;&#125;
&nbsp;
<nowiki>'''Sandbox'''</nowiki>
&nbsp;
&#123;&#123;''template''/sandbox&#124;''param1''=''value1''&#124;''param2''=''value2''&#125;&#125;
&nbsp;
&#123;&#123;clear&#125;&#125;
 
==== Wikitable ====
 
Using a wikitable to format test cases is often useful for templates with short output that need to be lined up correctly.
 
Start the table like this:
 
&#123;&#124; class="wikitable"
&#124;-
! Code
! Main
! Sandbox
 
Each new test case can be added like this:
 
|-
| &lt;code&gt;&lt;nowiki&gt;&#123;&#123;''template''&#124;''param1''=''value1''&#124;''param2''=''value2''&#125;&#125;&lt;/nowiki&gt;&lt;/code&gt;
| &#123;&#123;''template''&#124;''param1''=''value1''&#124;''param2''=''value2''&#125;&#125;
| &#123;&#123;''template''/sandbox&#124;''param1''=''value1''&#124;''param2''=''value2''&#125;&#125;
 
Finish the table like this:
 
&#124;&#125;
 
=== Automatic formatting ===