Difference between revisions of "Module:Example/testcases"

From blackwiki
Jump to navigation Jump to search
blackwiki>Dcoetzee
m (Dcoetzee moved page Module:Bananas/test to Module:Bananas/tests without leaving a redirect)
m (22 revisions imported)
 
(20 intermediate revisions by 9 users not shown)
Line 1: Line 1:
-- Unit tests for [[Module:Bananas]]. Click talk page to run tests.
+
-- Unit tests for [[Module:Example]]. Click talk page to run tests.
local UnitTests = require('Module:UnitTests')
+
local p = require('Module:UnitTests')
local p = UnitTests.UnitTester:new()
 
function p.run_tests(frame) return p:run(frame) end
 
  
 
function p:test_hello()
 
function p:test_hello()
     self:preprocess_equals('{{#invoke:Bananas | hello}}', 'Hello, world!')
+
     self:preprocess_equals('{{#invoke:Example | hello}}', 'Hello World!')
 
end
 
end
  
 +
function p:test_hello_to()
 +
    self:preprocess_equals('{{#invoke:Example|hello|Fred}}', 'Hello, Fred!')
 +
end
 +
 +
function p:test_count_fruit()
 +
    self:preprocess_equals('{{#invoke:Example|count_fruit|bananas=5|apples=3}}', 'I have 5 bananas and 3 apples')
 +
end
 
return p
 
return p

Latest revision as of 16:30, 26 September 2020

Documentation for this module may be created at Module:Example/testcases/doc

-- Unit tests for [[Module:Example]]. Click talk page to run tests.
local p = require('Module:UnitTests')

function p:test_hello()
    self:preprocess_equals('{{#invoke:Example | hello}}', 'Hello World!')
end

function p:test_hello_to()
    self:preprocess_equals('{{#invoke:Example|hello|Fred}}', 'Hello, Fred!')
end

function p:test_count_fruit()
    self:preprocess_equals('{{#invoke:Example|count_fruit|bananas=5|apples=3}}', 'I have 5 bananas and 3 apples')
end
return p