-- Unit tests for . Click talk page to run tests.local moduleName = 'WikiProject assessment progression/sandbox'local myModule = require('Module:' .. moduleName)local ScribuntoUnit = require('Module:ScribuntoUnit')local suite = ScribuntoUnit:new
function suite:calculateProjectTotal local projectTotal = self.frame:preprocess('' ) return projectTotalend
function suite:assertTypeEquals(expectedType, functionName, message) local outputType = type(functionName) self:assertEquals(expectedType, outputType, message)end
-- Confirm test function itself is workingfunction suite:test_assertTypeEquals_returns_correctly self:assertTypeEquals('number', 10, 'assertTypeEquals failed to compare value to its type')end
-- Confirm output is a number formatted as a stringfunction suite:test_module_outputs_number_as_string local asString = self.frame:preprocess('') local asNumber = tonumber(asString) self:assertTypeEquals('string', asString, 'Module output is not formatted as a string') self:assertTypeEquals('number', asNumber, 'Module output cannot be converted to a number')end
-- Confirm output returns expected valuefunction suite:test_module_outputs_expected_value local projectTotal = self:calculateProjectTotal local expectedOutput = self.frame:preprocess('') local moduleOutput = self.frame:preprocess('') self:assertEquals(expectedOutput, moduleOutput, 'Module output does not match expected calculation')end
-- Confirm output returns expected value for single classfunction suite:test_module_outputs_expected_for_single_class local projectTotal = self:calculateProjectTotal local expectedOutput = self.frame:preprocess('') local moduleOutput = self.frame:preprocess('') self:assertEquals(expectedOutput, moduleOutput, 'Module output differs for total on single class')end
--main|project=SPAceflight}}') self:assertEquals('Error: project not found for project name "SPAceflight"', invalidProject)end--return suite