Fandom Developers Wiki
Advertisement

This article is about a system or feature that is no longer in use.

The page is retained for historical reasons.

Reason: Superseded by Testharness.

For Scribunto unit testing, see Global Lua Modules/Testharness.
For full documentation, see wikipedia:Module:UnitTests/doc.

UnitTests is a class module from Wikipedia that enables unit test generation and module debugging in Scribunto.

Description[]

Unlike ScribuntoUnit, this framework can generate many tests for a single case. But ultimately it serves the same purpose of helping to debug modules.

Invocation functions:

u.run_tests
Executes the /testcases module.

Class functions:

u:new
Unit test constructor
u:preprocess_equals
Unit test for invocation vs. text string
Arguments: (text, expected, options)
u:preprocess_equals
Unit test for invocation vs. text string
Arguments: (text, expected, options)
u:preprocess_equals_many
Unit test for multiple preprocess_equals cases
Arguments: (prefix, suffix, cases, options)
u:preprocess_equals_preprocess
Unit test for invocation vs. preprocessed text string
Arguments: (text1, text2, options)
u:preprocess_equals_preprocess_many
Unit test for multiple preprocess_equals_preprocess cases
Arguments: (prefix1, suffix1, prefix2, suffix2, cases, options)
u:equals
Unit test for direct comparison of Lua variables
Arguments: (actual, expected, options)
u:equals_many
Unit test for multiple equals cases
Arguments: (cases, options)
u:equals_deep
Unit test for deep value comparison
Arguments: (name, actual, expected, options)
u:equals_deep_many
Unit test for multiple equals_deep cases
Arguments: (name, cases, options)

Internal/private functions:

  • Scribunto preprocessor (bypasses frame:preprocess bugs)
  • Value-string conversion
  • Table-string conversion
Advertisement