Wikipedia:Template sandbox and test cases: Difference between revisions

Reverted 1 edit by (talk) to last revision by JustBerry. (TW)
m (Reverted 1 edit by (talk) to last revision by JustBerry. (TW))
For navigational boxes with mostly identical results on each transcluding page, the benefit may not outweigh the time and effort to create a sandbox page, but if in doubt, sandbox it. Any template that is marked as a [[Wikipedia:High-risk templates|High-risk Template]] should always be tested before an edit is made. With other pages, you should still check which pages use the template (via the "What Links Here" link in the Tools section of the linkbar at the left side of the screen).
== How to create /sandbox and /testcases subpages ==
# Suppose your template is named <code>Template:X</code>. Create a subpage with the name <code>Template:X/sandbox</code>. If the main template is using the {{tl|documentation}} template, you can do this from a link at the bottom of the blue documentation box on the template main page. Or you can type it into the search box, or directly into the URL bar of your browser. Note that "/sandbox" is all lowercase.
# Copy the entire contents of the main template, including <code><nowiki><noinclude></nowiki></code> tags and the {{tl|documentation}} template if present, paste it into the edit window of the /sandbox subpage, and save the page. Your edit summary should be something like "create sandbox version of [[Template:X]]".
#* Note: if you use the "mirror" link at the bottom of the blue documentation box, tags like <code><nowiki><noinclude></nowiki></code>, and their contents, will be missing. It's best just to copy and paste manually.
# Create another subpage with the name <code>Template:X/testcases</code>. This page is only linked from the bottom of the blue documentation box if it actually exists, so to create it you will need to create it by typing the page name into the search box or into the URL bar of your browser. Again, note that "/testcases" is all lowercase, and all one word.
# Put the {{tl|testcases notice}} template at the top of the page, add some test cases (see below), and save the page.
# Add your experimental code to <code>Template:X/sandbox</code>. To test your code, save the page, and go to the /testcases page. Often you will need to [[WP:PURGE|purge]] the /testcases page to see the updated results; there is a link to do that included in the {{tl|testcases notice}} template. After you've purged the page, compare the results for the main template with the results from the sandbox, and if everything looks okay, you can update the main template. However, be wary of missing test cases and of code that can only be tested in certain namespaces or on certain pages.
== How to update existing /sandbox and /testcases subpages ==