Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:ScribuntoUnit/doc
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Test module structure == To make a test module (test suite), start with the following code: <syntaxhighlight lang="lua"> local ScribuntoUnit = require('Module:ScribuntoUnit') local myModule = require('Module:MyModule') -- the module to be tested local suite = ScribuntoUnit:new() </syntaxhighlight> After you have done this you can add individual test functions to the <code>suite</code> object. Any function that begins with <code>test</code> is treated as a test. (Other functions will be ignored by ScribuntoUnit, but can be used in the tests themselves.) <syntaxhighlight lang="lua"> function suite:testSomeCall() self:assertEquals('expected value', myModule.someCall(123)) self:assertEquals('other expected value', myModule.someCall(456)) end function suite:testSomeOtherCall() self:assertEquals('expected value', myModule.someOtherCall(123)) self:assertEquals('other expected value', myModule.someOtherCall(456)) end </syntaxhighlight> The tests you write should make assertions, and ScribuntoUnit will check whether those assertions are true. For example, <code>assertEquals</code> checks that both of the arguments it is given are equal. If ScribuntoUnit doesn't find an assertion to be true, then the test will fail and an error message will be generated. The error message will show which assertion failed verification (other checks on the assertions are not made at this time). To finish the test module, you need to return the <code>suite</code> object. <syntaxhighlight lang="lua"> return suite </syntaxhighlight>
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)