Hopp til innhold

Modul:Template test case

Fra Wikipedia, den frie encyklopedi
Sideversjon per 21. nov. 2014 kl. 08:10 av en>Mr. Stradivarius (first draft of the spec for a generalised template test cases module)
(diff) ← Eldre sideversjon | Nåværende sideversjon (diff) | Nyere sideversjon → (diff)
Moduldokumentasjon

This module provides a framework for making templates which produce a template test case. While test cases can be made manually, using Lua-based templates such as the ones provided by this module has the advantage that the template arguments only need to be input once, thus reducing the effort involved in making test cases and reducing the possibility of errors in the input.

Usage

This module should not usually be called directly. Instead, you should use one of the following templates:

Parameter-based templates:

The only difference between these templates is their default arguments. For example, it is possible to display test cases side by side in Template:Testcase rows by specifying |_format=columns

Nowiki-based templates:

It is also possible to use a format of {{#invoke:template test case|main|parameters}}. This uses the same defaults as Template:Test case; please see that page for documentation of the parameters.

There is no direct interface to this module for other Lua modules. Lua modules should generally use Lua-based test case modules such as Module:UnitTests or Module:ScribuntoUnit. If it is really necessary to use this module, you can use frame:expandTemplate with one of the templates listed above.

Configuration

This module has a configuration module at Module:Template test case/config. You can edit it to add new wrapper templates, or to change the messages that the module outputs.

Tracking categories

-- This module provides several methods to generate test cases.

--------------------------------------------------------------------------------
-- Test case display functions
--
-- Test case display functions produce the wikitext to display the template
-- output for one test case. For example, one function might produce templates
-- aligned horizontally, and another function might produce templates aligned
-- one below the other.
--
-- They are named functions that accept the following parameters:
-- * templates - an array of subtables containing data about each template to be
--     displayed. These subtables can contain the following values:
--     * result - the expanded wikitext from the template.
--     * invocation - the original unexpanded wikitext that the output was
--         generated from. This may be nil if the invocation is not available.
--     * name - the name of the template.
--     * link - a normal wikilink to the template page (displays as
--         "Template:Foo").
--     * braceLink - a wikilink to the template page formatted like the {{tl}}
--         template, i.e. it displays as "{{Foo}}".
--     * heading - a heading to display above the template output.
--------------------------------------------------------------------------------