From 32faa192158081b8c2f325236dfc9592b377c610 Mon Sep 17 00:00:00 2001 From: George Cook Date: Sun, 4 Oct 2020 16:42:26 -0500 Subject: [PATCH] refactoring to reflect new plugin-driven pattenr --- .vscode/launch.json | 2 +- package-lock.json | 6 +- src/source/BaseTestSuite.bs | 3424 +++++++++-------- src/source/CommonUtils.bs | 132 +- src/source/Coverage.bs | 2 +- src/source/Matchers.bs | 14 +- src/source/Rooibos.bs | 232 +- src/source/RooibosScene.xml | 50 + src/source/RuntimeConfig.bs | 48 +- src/source/Stats.bs | 78 +- src/source/Test.bs | 196 +- src/source/TestGroup.bs | 139 +- src/source/TestLogger.bs | 242 +- src/source/TestResult.bs | 114 +- src/source/TestRunner.bs | 319 +- src/source/framework.bs | 11 - src/source/scratch.bs | 1611 ++++++++ .../{AssertionTests.bs => Assertion.spec.bs} | 221 +- tests/src/source/Basic.spec.bs | 83 + tests/src/source/BasicTests.bs | 81 - tests/src/source/Common.spec.bs | 30 + tests/src/source/CommonTests.bs | 27 - tests/src/source/Expect.spec.bs | 58 + tests/src/source/ExpectTests.bs | 55 - tests/src/source/Matcher.spec.bs | 212 + tests/src/source/MatcherTests.bs | 211 - tests/src/source/NodeExample.spec.bs | 37 + tests/src/source/NodeExampleTests.bs | 39 - tests/src/source/Params.spec.bs | 36 + tests/src/source/ParamsTests.bs | 35 - tests/src/source/Version.spec.bs | 28 + tests/src/source/VersionTests.bs | 26 - .../source/issue_13_afterEach_not_running.bs | 51 - .../issue_13_afterEach_not_running.spec.bs | 54 + .../source/issue_15_tests_only_on_groups.bs | 31 - .../issue_15_tests_only_on_groups.spec.bs | 33 + .../src/source/issue_5_duplicateGroupNames.bs | 32 - .../issue_5_duplicateGroupNames.spec.bs | 34 + tests/src/source/main.bs | 37 - tests/src/source/rooibos-framework.bs | 11 - tests/src/source/testConfig.json | 5 - tests/src/source/verifyBeforeEachAfterEach.bs | 102 - .../source/verifyBeforeEachAfterEach.spec.bs | 100 + tests/src/tests/AssertionTests.bs | 637 --- tests/src/tests/BasicTests.bs | 81 - tests/src/tests/CommonTests.bs | 28 - tests/src/tests/ExpectTests.bs | 55 - tests/src/tests/MatcherTests.bs | 211 - tests/src/tests/NodeExampleTests.bs | 39 - tests/src/tests/ParamsTests.bs | 35 - tests/src/tests/VersionTests.bs | 26 - .../tests/issue_13_afterEach_not_running.bs | 51 - .../tests/issue_15_tests_only_on_groups.bs | 31 - .../src/tests/issue_5_duplicateGroupNames.bs | 32 - tests/src/tests/testConfig.json | 5 - tests/src/tests/testUtils.bs | 8 - tests/src/tests/verifyBeforeEachAfterEach.bs | 102 - 57 files changed, 4923 insertions(+), 4707 deletions(-) create mode 100644 src/source/RooibosScene.xml delete mode 100644 src/source/framework.bs create mode 100644 src/source/scratch.bs rename tests/src/source/{AssertionTests.bs => Assertion.spec.bs} (75%) create mode 100644 tests/src/source/Basic.spec.bs delete mode 100644 tests/src/source/BasicTests.bs create mode 100644 tests/src/source/Common.spec.bs delete mode 100644 tests/src/source/CommonTests.bs create mode 100644 tests/src/source/Expect.spec.bs delete mode 100644 tests/src/source/ExpectTests.bs create mode 100644 tests/src/source/Matcher.spec.bs delete mode 100644 tests/src/source/MatcherTests.bs create mode 100644 tests/src/source/NodeExample.spec.bs delete mode 100644 tests/src/source/NodeExampleTests.bs create mode 100644 tests/src/source/Params.spec.bs delete mode 100644 tests/src/source/ParamsTests.bs create mode 100644 tests/src/source/Version.spec.bs delete mode 100644 tests/src/source/VersionTests.bs delete mode 100644 tests/src/source/issue_13_afterEach_not_running.bs create mode 100644 tests/src/source/issue_13_afterEach_not_running.spec.bs delete mode 100644 tests/src/source/issue_15_tests_only_on_groups.bs create mode 100644 tests/src/source/issue_15_tests_only_on_groups.spec.bs delete mode 100644 tests/src/source/issue_5_duplicateGroupNames.bs create mode 100644 tests/src/source/issue_5_duplicateGroupNames.spec.bs delete mode 100644 tests/src/source/main.bs delete mode 100644 tests/src/source/rooibos-framework.bs delete mode 100644 tests/src/source/testConfig.json delete mode 100644 tests/src/source/verifyBeforeEachAfterEach.bs create mode 100644 tests/src/source/verifyBeforeEachAfterEach.spec.bs delete mode 100644 tests/src/tests/AssertionTests.bs delete mode 100644 tests/src/tests/BasicTests.bs delete mode 100644 tests/src/tests/CommonTests.bs delete mode 100644 tests/src/tests/ExpectTests.bs delete mode 100644 tests/src/tests/MatcherTests.bs delete mode 100644 tests/src/tests/NodeExampleTests.bs delete mode 100644 tests/src/tests/ParamsTests.bs delete mode 100644 tests/src/tests/VersionTests.bs delete mode 100644 tests/src/tests/issue_13_afterEach_not_running.bs delete mode 100644 tests/src/tests/issue_15_tests_only_on_groups.bs delete mode 100644 tests/src/tests/issue_5_duplicateGroupNames.bs delete mode 100644 tests/src/tests/testConfig.json delete mode 100644 tests/src/tests/testUtils.bs delete mode 100644 tests/src/tests/verifyBeforeEachAfterEach.bs diff --git a/.vscode/launch.json b/.vscode/launch.json index bb972c03..21118f6f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -17,7 +17,7 @@ "request": "launch", "name": "TEST", "internalConsoleOptions": "neverOpen", - "envFile": "${workspaceFolder}/devstuff/.env", + "envFile": "${workspaceFolder}/.vscode/.env", "preLaunchTask": "buildTests", "host": "${env:ROKU_DEV_TARGET}", "password": "${env:ROKU_DEVPASSWORD}", diff --git a/package-lock.json b/package-lock.json index 79cb20a2..f578ee4b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -339,9 +339,9 @@ } }, "brighterscript": { - "version": "0.15.0", - "resolved": "https://registry.npmjs.org/brighterscript/-/brighterscript-0.15.0.tgz", - "integrity": "sha512-Tdfdls1JHoT2IXZCo2dqPArOPgCUu12xhxEjXTIDRydXXxfVh22oGQx5OvYJ4II7qk4QzjNVS0rthP1JDSOJiw==", + "version": "0.15.2", + "resolved": "https://registry.npmjs.org/brighterscript/-/brighterscript-0.15.2.tgz", + "integrity": "sha512-D/Rn8HJycYqKb2J6JiGIk7ipDfJK4CoM607MyOKIe6S0loz57tR769ykQVFj+EuFijqBW+9RTya/25BV7dJ0Lw==", "dev": true, "requires": { "@types/yargs": "^15.0.5", diff --git a/src/source/BaseTestSuite.bs b/src/source/BaseTestSuite.bs index fd36ad24..cccebf3e 100644 --- a/src/source/BaseTestSuite.bs +++ b/src/source/BaseTestSuite.bs @@ -1,380 +1,323 @@ -' /** -' * @module TestSuite -' * @description All brs files that include `'@TestSuite` annotations automatically extend the TestSuite. -' * The base test suite contains all of the assertions, and utility methods required to writey our tests, as well as being responsible for tracking the state of the tests and groups. -' */ -class BaseTestSuite - - 'test state - name = "BaseTestSuite" 'set the name to the name of your test - - filePath = invalid - pkgPath = invalid - isValid = false - hasSoloTests = false - hasIgnoredTests = false - isSolo = false - isIgnored = false - isNodeTest = false - nodeName = invalid - groups = [] - groupsData = [] - stats = invalid - - 'special values - invalidValue = "#ROIBOS#INVALID_VALUE" ' special value used in mock arguments - ignoreValue = "#ROIBOS#IGNORE_VALUE" ' special value used in mock arguments - - 'built in any matchers - anyStringMatcher = { "matcher": Rooibos_Matcher_anyString } - anyBoolMatcher = { "matcher": Rooibos_Matcher_anyBool } - anyNumberMatcher = { "matcher": Rooibos_Matcher_anyNumber } - anyAAMatcher = { "matcher": Rooibos_Matcher_anyAA } - anyArrayMatcher = { "matcher": Rooibos_Matcher_anyArray } - anyNodeMatcher = { "matcher": Rooibos_Matcher_anyNode } - allowNonExistingMethodsOnMocks = true - isAutoAssertingMocks = true - - currentResult = invalid - - protected global = invalid - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '++ base methods to override - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - function new(testSuite, data, runHasSoloTests, nodeContext, failFast) - m.testSuite = testSuite - m.runHasSoloTests = runHasSoloTests - m.name = data.name - m.filePath = data.filePath - m.pkgPath = data.pkgPath - m.valid = data.valid - m.hasFailures = data.hasFailures - m.hasSoloTests = data.hasSoloTests - m.hasIgnoredTests = data.hasIgnoredTests - m.hasSoloGroups = data.hasSoloGroups - m.isSolo = data.isSolo - m.isIgnored = data.isIgnored - m.groupsData = data.groups - m.isNodeTest = false - m.nodeName = invalid - m.isFailingFast = false - m.stats = new Stats() - m.global = nodeContext.global - m.context = nodeContext - m.top = nodeContext.top - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '++ used for entire suite - use annotations to use elsewhere - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - protected function setup() - end function - - protected function tearDown() - end function - - protected function beforeEach() - end function - - protected function afterEach() - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '++ running - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - function run() - for each groupData in m.groupsData - - group = new TestGroup(m, testData) - m.groups.push(group) - group.run() - - m.stats.merge(group.stats) - - if m.stats.hasFailures and m.isFailingFast = true - ? "Terminating suite due to failed group" - exit for - end if - - end for - end function - - function runTest(test) - m.currentResult = test.result - test.run() - - if m.isAutoAssertingMocks = true - m.AssertMocks() - m.CleanMocks() - m.CleanStubs() - end if - - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '++ Assertions - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - +namespace Rooibos ' /** - ' * @memberof module:BaseTestSuite - ' * @name fail - ' * @function - ' * @instance - ' * @description Fail immediately, with the given message - ' * @param {Dynamic} [msg=""] - message to display in the test report - ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' * @module TestSuite + ' * @description All brs files that include `'@TestSuite` annotations automatically extend the TestSuite. + ' * The base test suite contains all of the assertions, and utility methods required to writey our tests, as well as being responsible for tracking the state of the tests and groups. ' */ - function fail(msg = "Error", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - m.currentResult.fail(msg, lineNumber) - return false - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertFalse - ' * @function - ' * @instance - ' * @description Fail the test if the expression is true. - ' * @param {Dynamic} expr - An expression to evaluate. - ' * @param {Dynamic} [msg=""] - alternate error message - ' Default value: "Expression evaluates to true"' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertFalse(expr, msg = "Expression evaluates to true", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if not Common.isBoolean(expr) or expr - return m.fail(msg) - end if - m.currentResult.fail("", -1) - return true - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertTrue - ' * @function - ' * @instance - ' * @description Fail the test unless the expression is true. - ' * @param {Dynamic} expr - An expression to evaluate. - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertTrue(expr, msg = "Expression evaluates to false", lineNumber = -1) - if m.currentResult.isFail then return false + class BaseTestSuite + + 'test state + name = "BaseTestSuite" 'set the name to the name of your test + + filePath = invalid + pkgPath = invalid + isValid = false + hasSoloTests = false + hasIgnoredTests = false + isSolo = false + isIgnored = false + isNodeTest = false + nodeName = invalid + groups = [] + groupsData = [] + stats = invalid + + 'special values + invalidValue = "#ROIBOS#INVALID_VALUE" ' special value used in mock arguments + ignoreValue = "#ROIBOS#IGNORE_VALUE" ' special value used in mock arguments + + 'built in any matchers + anyStringMatcher = { "matcher": Rooibos_Matcher_anyString } + anyBoolMatcher = { "matcher": Rooibos_Matcher_anyBool } + anyNumberMatcher = { "matcher": Rooibos_Matcher_anyNumber } + anyAAMatcher = { "matcher": Rooibos_Matcher_anyAA } + anyArrayMatcher = { "matcher": Rooibos_Matcher_anyArray } + anyNodeMatcher = { "matcher": Rooibos_Matcher_anyNode } + allowNonExistingMethodsOnMocks = true + isAutoAssertingMocks = true + + currentResult = invalid + + protected global = invalid + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '++ base methods to override + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + function new(nodeContext) + data = m.getTestSuitedata() + m.name = data.name + m.filePath = data.filePath + m.pkgPath = data.pkgPath + m.valid = data.valid + m.hasFailures = data.hasFailures + m.hasSoloTests = data.hasSoloTests + m.hasIgnoredTests = data.hasIgnoredTests + m.hasSoloGroups = data.hasSoloGroups + m.isSolo = data.isSolo + m.isIgnored = data.isIgnored + m.groupsData = data.groups + m.isNodeTest = false + m.nodeName = invalid + m.isFailingFast = false + m.stats = new Stats() + m.global = nodeContext.global + m.context = nodeContext + m.top = nodeContext.top + end function + + function getTestSuiteData() + 'this will be injected by the plugin + end function + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '++ used for entire suite - use annotations to use elsewhere + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + protected function setup() + end function + + protected function tearDown() + end function + + protected function beforeEach() + end function + + protected function afterEach() + end function + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '++ running + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + function run() + for each groupData in m.groupsData + 'bs:disable-next-line + group = new TestGroup(m, data) + m.groups.push(group) + group.run() + + m.stats.merge(group.stats) + + if m.stats.hasFailures and m.isFailingFast = true + ? "Terminating suite due to failed group" + exit for + end if - if not Common.isBoolean(expr) or not expr - m.currentResult.fail(msg, lineNumber) - return false - end if + end for + end function - m.currentResult.fail("", -1) - return true - end function + function runTest(test) + m.currentResult = test.result + test.run() - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertEqual - ' * @function - ' * @instance - ' * @description Fail if the two objects are unequal as determined by the '<>' operator. - ' * @param {Dynamic} first - first object to compare - ' * @param {Dynamic} second - second object to compare - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertEqual(first, second, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if not Common.eqValues(first, second) - if msg = "" - first_as_string = Common.asString(first) - second_as_string = Common.asString(second) - msg = first_as_string + " != " + second_as_string + if m.isAutoAssertingMocks = true + m.AssertMocks() + m.CleanMocks() + m.CleanStubs() end if - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertLike - ' * @function - ' * @instance - ' * @description does a fuzzy comparison - ' * @param {Dynamic} first - first object to compare - ' * @param {Dynamic} second - second object to compare - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertLike(first, second, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if first <> second - if msg = "" - first_as_string = Common.asString(first) - second_as_string = Common.asString(second) - msg = first_as_string + " != " + second_as_string - end if + end function + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '++ Assertions + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name fail + ' * @function + ' * @instance + ' * @description Fail immediately, with the given message + ' * @param {Dynamic} [msg=""] - message to display in the test report + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function fail(msg = "Error", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false m.currentResult.fail(msg, lineNumber) return false - end if - m.currentResult.fail("", -1) - return true - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertNotEqual - ' * @function - ' * @instance - ' * @description Fail if the two objects are equal as determined by the '=' operator. - ' * @param {Dynamic} first - first object to compare - ' * @param {Dynamic} second - second object to compare - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertNotEqual(first, second, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if Common.eqValues(first, second) - if msg = "" - first_as_string = Common.asString(first) - second_as_string = Common.asString(second) - msg = first_as_string + " == " + second_as_string + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertFalse + ' * @function + ' * @instance + ' * @description Fail the test if the expression is true. + ' * @param {Dynamic} expr - An expression to evaluate. + ' * @param {Dynamic} [msg=""] - alternate error message + ' Default value: "Expression evaluates to true"' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertFalse(expr, msg = "Expression evaluates to true", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if not Rooibos.Common.isBoolean(expr) or expr + return m.fail(msg) end if - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertInvalid - ' * @function - ' * @instance - ' * @description Fail if the value is not invalid. - ' * @param {Dynamic} value - value to check - value to check for - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertInvalid(value, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if value <> invalid - if msg = "" - expr_as_string = Common.asString(value) - msg = expr_as_string + " <> Invalid" + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertTrue + ' * @function + ' * @instance + ' * @description Fail the test unless the expression is true. + ' * @param {Dynamic} expr - An expression to evaluate. + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertTrue(expr, msg = "Expression evaluates to false", lineNumber = -1) + if m.currentResult.isFail then return false + + if not Rooibos.Common.isBoolean(expr) or not expr + m.currentResult.fail(msg, lineNumber) + return false end if - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertNotInvalid - ' * @function - ' * @instance - ' * @description Fail if the value is invalid. - ' * @param {Dynamic} value - value to check - value to check for - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertNotInvalid(value, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if value = invalid - if msg = "" - expr_as_string = Common.asString(value) - msg = expr_as_string + " = Invalid" + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertEqual + ' * @function + ' * @instance + ' * @description Fail if the two objects are unequal as determined by the '<>' operator. + ' * @param {Dynamic} first - first object to compare + ' * @param {Dynamic} second - second object to compare + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertEqual(first, second, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if not Rooibos.Common.eqValues(first, second) + if msg = "" + first_as_string = Rooibos.Common.asString(first) + second_as_string = Rooibos.Common.asString(second) + msg = first_as_string + " != " + second_as_string + end if + m.currentResult.fail(msg, lineNumber) + return false end if - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertAAHasKey - ' * @function - ' * @instance - ' * @description Fail if the array doesn't have the key. - ' * @param {Dynamic} array - target array - ' * @param {Dynamic} key - key name - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertAAHasKey(array, key, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if Common.isAssociativeArray(array) - if not array.DoesExist(key) + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertLike + ' * @function + ' * @instance + ' * @description does a fuzzy comparison + ' * @param {Dynamic} first - first object to compare + ' * @param {Dynamic} second - second object to compare + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertLike(first, second, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if first <> second if msg = "" - msg = "Array doesn't have the '" + key + "' key." + first_as_string = Rooibos.Common.asString(first) + second_as_string = Rooibos.Common.asString(second) + msg = first_as_string + " != " + second_as_string end if m.currentResult.fail(msg, lineNumber) return false end if - else - msg = "Input value is not an Associative Array." - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertAANotHasKey - ' * @function - ' * @instance - ' * @description Fail if the array has the key. - ' * @param {Dynamic} array - target array - ' * @param {Dynamic} key - key name - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertAANotHasKey(array, key, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if Common.isAssociativeArray(array) - if array.DoesExist(key) + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertNotEqual + ' * @function + ' * @instance + ' * @description Fail if the two objects are equal as determined by the '=' operator. + ' * @param {Dynamic} first - first object to compare + ' * @param {Dynamic} second - second object to compare + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertNotEqual(first, second, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if Rooibos.Common.eqValues(first, second) if msg = "" - msg = "Array has the '" + key + "' key." + first_as_string = Rooibos.Common.asString(first) + second_as_string = Rooibos.Common.asString(second) + msg = first_as_string + " == " + second_as_string end if m.currentResult.fail(msg, lineNumber) return false end if - else - msg = "Input value is not an Associative Array." - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertAAHasKeys - ' * @function - ' * @instance - ' * @description Fail if the array doesn't have the keys list. - ' * @param {Dynamic} array - A target associative array. - ' * @param {Dynamic} keys - Array of key names. - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertAAHasKeys(array, keys, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if Common.isAssociativeArray(array) and Common.isArray(keys) - for each key in keys + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertInvalid + ' * @function + ' * @instance + ' * @description Fail if the value is not invalid. + ' * @param {Dynamic} value - value to check - value to check for + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertInvalid(value, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if value <> invalid + if msg = "" + expr_as_string = Rooibos.Common.asString(value) + msg = expr_as_string + " <> Invalid" + end if + m.currentResult.fail(msg, lineNumber) + return false + end if + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertNotInvalid + ' * @function + ' * @instance + ' * @description Fail if the value is invalid. + ' * @param {Dynamic} value - value to check - value to check for + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertNotInvalid(value, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if value = invalid + if msg = "" + expr_as_string = Rooibos.Common.asString(value) + msg = expr_as_string + " = Invalid" + end if + m.currentResult.fail(msg, lineNumber) + return false + end if + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertAAHasKey + ' * @function + ' * @instance + ' * @description Fail if the array doesn't have the key. + ' * @param {Dynamic} array - target array + ' * @param {Dynamic} key - key name + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertAAHasKey(array, key, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if Rooibos.Common.isAssociativeArray(array) if not array.DoesExist(key) if msg = "" msg = "Array doesn't have the '" + key + "' key." @@ -382,31 +325,29 @@ class BaseTestSuite m.currentResult.fail(msg, lineNumber) return false end if - end for - else - msg = "Input value is not an Associative Array." - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertAANotHasKeys - ' * @function - ' * @instance - ' * @description Fail if the array has the keys list. - ' * @param {Dynamic} array - A target associative array. - ' * @param {Dynamic} keys - Array of key names. - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertAANotHasKeys(array, keys, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if Common.isAssociativeArray(array) and Common.isArray(keys) - for each key in keys + else + msg = "Input value is not an Associative Array." + m.currentResult.fail(msg, lineNumber) + return false + end if + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertAANotHasKey + ' * @function + ' * @instance + ' * @description Fail if the array has the key. + ' * @param {Dynamic} array - target array + ' * @param {Dynamic} key - key name + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertAANotHasKey(array, key, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if Rooibos.Common.isAssociativeArray(array) if array.DoesExist(key) if msg = "" msg = "Array has the '" + key + "' key." @@ -414,1453 +355,1518 @@ class BaseTestSuite m.currentResult.fail(msg, lineNumber) return false end if - end for - else - msg = "Input value is not an Associative Array." - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - - - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertArrayContains - ' * @function - ' * @instance - ' * @description Fail if the array doesn't have the item. - ' * @param {Dynamic} array - target array - ' * @param {Dynamic} value - value to check - value to check for - ' * @param {Dynamic} key - key name in associative array - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertArrayContains(array, value, key = invalid, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if Common.isAssociativeArray(array) or Common.isArray(array) - if not Common.arrayContains(array, value, key) - msg = "Array doesn't have the '" + Common.asString(value) + "' value." + else + msg = "Input value is not an Associative Array." m.currentResult.fail(msg, lineNumber) return false end if - else - msg = "Input value is not an Array." - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertArrayContainsAAs - ' * @function - ' * @instance - ' * @description Fail if the array does not contain all of the aa's in the values array. - ' * @param {Dynamic} array - target array - ' * @param {Dynamic} values - array of aas to look for in target array - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertArrayContainsAAs(array, values, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - - if not Common.isArray(values) - msg = "values to search for are not an Array." - m.currentResult.fail(msg, lineNumber) - return false - end if - - if Common.isArray(array) - for each value in values - isMatched = false - if not Common.isAssociativeArray(value) - msg = "Value to search for was not associativeArray " + Common.asString(value) + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertAAHasKeys + ' * @function + ' * @instance + ' * @description Fail if the array doesn't have the keys list. + ' * @param {Dynamic} array - A target associative array. + ' * @param {Dynamic} keys - Array of key names. + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertAAHasKeys(array, keys, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if Rooibos.Common.isAssociativeArray(array) and Rooibos.Common.isArray(keys) + for each key in keys + if not array.DoesExist(key) + if msg = "" + msg = "Array doesn't have the '" + key + "' key." + end if + m.currentResult.fail(msg, lineNumber) + return false + end if + end for + else + msg = "Input value is not an Associative Array." + m.currentResult.fail(msg, lineNumber) + return false + end if + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertAANotHasKeys + ' * @function + ' * @instance + ' * @description Fail if the array has the keys list. + ' * @param {Dynamic} array - A target associative array. + ' * @param {Dynamic} keys - Array of key names. + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertAANotHasKeys(array, keys, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if Rooibos.Common.isAssociativeArray(array) and Rooibos.Common.isArray(keys) + for each key in keys + if array.DoesExist(key) + if msg = "" + msg = "Array has the '" + key + "' key." + end if + m.currentResult.fail(msg, lineNumber) + return false + end if + end for + else + msg = "Input value is not an Associative Array." + m.currentResult.fail(msg, lineNumber) + return false + end if + m.currentResult.fail("", -1) + return true + end function + + + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertArrayContains + ' * @function + ' * @instance + ' * @description Fail if the array doesn't have the item. + ' * @param {Dynamic} array - target array + ' * @param {Dynamic} value - value to check - value to check for + ' * @param {Dynamic} key - key name in associative array + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertArrayContains(array, value, key = invalid, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if Rooibos.Common.isAssociativeArray(array) or Rooibos.Common.isArray(array) + if not Rooibos.Common.arrayContains(array, value, key) + msg = "Array doesn't have the '" + Rooibos.Common.asString(value) + "' value." m.currentResult.fail(msg, lineNumber) return false end if - for each item in array - if Common.IsAssociativeArray(item) - isValueMatched = true - for each key in value - fieldValue = value[key] - itemValue = item[key] - if not Common.eqValues(fieldValue, itemValue) - isValueMatched = false + else + msg = "Input value is not an Array." + m.currentResult.fail(msg, lineNumber) + return false + end if + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertArrayContainsAAs + ' * @function + ' * @instance + ' * @description Fail if the array does not contain all of the aa's in the values array. + ' * @param {Dynamic} array - target array + ' * @param {Dynamic} values - array of aas to look for in target array + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertArrayContainsAAs(array, values, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + + if not Rooibos.Common.isArray(values) + msg = "values to search for are not an Array." + m.currentResult.fail(msg, lineNumber) + return false + end if + + if Rooibos.Common.isArray(array) + for each value in values + isMatched = false + if not Rooibos.Common.isAssociativeArray(value) + msg = "Value to search for was not associativeArray " + Rooibos.Common.asString(value) + m.currentResult.fail(msg, lineNumber) + return false + end if + for each item in array + if Rooibos.Common.IsAssociativeArray(item) + isValueMatched = true + for each key in value + fieldValue = value[key] + itemValue = item[key] + if not Rooibos.Common.eqValues(fieldValue, itemValue) + isValueMatched = false + exit for + end if + end for + if isValueMatched + isMatched = true exit for end if - end for - if isValueMatched - isMatched = true - exit for end if - end if - end for ' items in array + end for ' items in array - if not isMatched - msg = "array missing value: " + Common.asString(value) - m.currentResult.fail(msg, lineNumber) - return false - end if - - end for 'values to match - else - msg = "Input value is not an Array." - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function + if not isMatched + msg = "array missing value: " + Rooibos.Common.asString(value) + m.currentResult.fail(msg, lineNumber) + return false + end if - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertArrayNotContains - ' * @function - ' * @instance - ' * @description Fail if the array has the item. - ' * @param {Dynamic} array - target array - ' * @param {Dynamic} array - target array - ' * @param {Dynamic} value - value to check - Value to check for - ' * @param {Dynamic} key - A key name for associative array. - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertArrayNotContains(array, value, key = invalid, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if Common.isAssociativeArray(array) or Common.isArray(array) - if Common.arrayContains(array, value, key) - msg = "Array has the '" + Common.asString(value) + "' value." + end for 'values to match + else + msg = "Input value is not an Array." m.currentResult.fail(msg, lineNumber) return false end if - else - msg = "Input value is not an Array." - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertArrayContainsSubset - ' * @function - ' * @instance - ' * @description Fail if the array doesn't have the item subset. - ' * @param {Dynamic} array - target array - ' * @param {Dynamic} subset - items to check presnece of - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertArrayContainsSubset(array, subset, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if (Common.isAssociativeArray(array) and Common.isAssociativeArray(subset)) or (Common.isArray(array) and Common.isArray(subset)) - isAA = Common.isAssociativeArray(subset) - for each item in subset - key = invalid - value = item - if isAA - key = item - value = subset[key] - end if - if not Common.arrayContains(array, value, key) - msg = "Array doesn't have the '" + Common.asString(value) + "' value." - m.currentResult.fail(msg, lineNumber) - return false - end if - end for - else - msg = "Input value is not an Array." - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertArrayNotContainsSubset - ' * @function - ' * @instance - ' * @description Fail if the array have the item from subset. - ' * @param {Dynamic} array - target array - ' * @param {Dynamic} subset - items to check presnece of - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertArrayNotContainsSubset(array, subset, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if (Common.isAssociativeArray(array) and Common.isAssociativeArray(subset)) or (Common.isArray(array) and Common.isArray(subset)) - isAA = Common.isAssociativeArray(subset) - for each item in subset - key = invalid - value = item - if isAA - key = item - value = item[key] - end if - if Common.arrayContains(array, value, key) - msg = "Array has the '" + Common.asString(value) + "' value." + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertArrayNotContains + ' * @function + ' * @instance + ' * @description Fail if the array has the item. + ' * @param {Dynamic} array - target array + ' * @param {Dynamic} array - target array + ' * @param {Dynamic} value - value to check - Value to check for + ' * @param {Dynamic} key - A key name for associative array. + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertArrayNotContains(array, value, key = invalid, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if Rooibos.Common.isAssociativeArray(array) or Rooibos.Common.isArray(array) + if Rooibos.Common.arrayContains(array, value, key) + msg = "Array has the '" + Rooibos.Common.asString(value) + "' value." m.currentResult.fail(msg, lineNumber) return false end if - end for - else - msg = "Input value is not an Array." - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertArrayCount - ' * @function - ' * @instance - ' * @description Fail if the array items count <> expected count - ' * @param {Dynamic} array - target array - ' * @param {Dynamic} count - An expected array items count - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertArrayCount(array, count, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if Common.isAssociativeArray(array) or Common.isArray(array) - if array.Count() <> count - msg = "Array items count " + Common.asString(array.Count()) + " <> " + Common.asString(count) + "." + else + msg = "Input value is not an Array." m.currentResult.fail(msg, lineNumber) return false end if - else - msg = "Input value is not an Array." - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertArrayNotCount - ' * @function - ' * @instance - ' * @description Fail if the array items count = expected count. - ' * @param {Dynamic} array - target array - ' * @param {Dynamic} count - An expected array items count. - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertArrayNotCount(array, count, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if Common.isAssociativeArray(array) or Common.isArray(array) - if array.Count() = count - msg = "Array items count = " + Common.asString(count) + "." + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertArrayContainsSubset + ' * @function + ' * @instance + ' * @description Fail if the array doesn't have the item subset. + ' * @param {Dynamic} array - target array + ' * @param {Dynamic} subset - items to check presnece of + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertArrayContainsSubset(array, subset, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if (Rooibos.Common.isAssociativeArray(array) and Rooibos.Common.isAssociativeArray(subset)) or (Rooibos.Common.isArray(array) and Rooibos.Common.isArray(subset)) + isAA = Rooibos.Common.isAssociativeArray(subset) + for each item in subset + key = invalid + value = item + if isAA + key = item + value = subset[key] + end if + if not Rooibos.Common.arrayContains(array, value, key) + msg = "Array doesn't have the '" + Rooibos.Common.asString(value) + "' value." + m.currentResult.fail(msg, lineNumber) + return false + end if + end for + else + msg = "Input value is not an Array." m.currentResult.fail(msg, lineNumber) return false end if - else - msg = "Input value is not an Array." - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertEmpty - ' * @function - ' * @instance - ' * @description Fail if the item is not empty array or string. - ' * @param {Dynamic} item - item to check - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertEmpty(item, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if Common.isAssociativeArray(item) or Common.isArray(item) - if item.count() > 0 - msg = "Array is not empty." + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertArrayNotContainsSubset + ' * @function + ' * @instance + ' * @description Fail if the array have the item from subset. + ' * @param {Dynamic} array - target array + ' * @param {Dynamic} subset - items to check presnece of + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertArrayNotContainsSubset(array, subset, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if (Rooibos.Common.isAssociativeArray(array) and Rooibos.Common.isAssociativeArray(subset)) or (Rooibos.Common.isArray(array) and Rooibos.Common.isArray(subset)) + isAA = Rooibos.Common.isAssociativeArray(subset) + for each item in subset + key = invalid + value = item + if isAA + key = item + value = item[key] + end if + if Rooibos.Common.arrayContains(array, value, key) + msg = "Array has the '" + Rooibos.Common.asString(value) + "' value." + m.currentResult.fail(msg, lineNumber) + return false + end if + end for + else + msg = "Input value is not an Array." m.currentResult.fail(msg, lineNumber) return false end if - else if Common.isString(item) - if Common.asString(item) <> "" - msg = "Input value is not empty." + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertArrayCount + ' * @function + ' * @instance + ' * @description Fail if the array items count <> expected count + ' * @param {Dynamic} array - target array + ' * @param {Dynamic} count - An expected array items count + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertArrayCount(array, count, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if Rooibos.Common.isAssociativeArray(array) or Rooibos.Common.isArray(array) + if array.Count() <> count + msg = "Array items count " + Rooibos.Common.asString(array.Count()) + " <> " + Rooibos.Common.asString(count) + "." + m.currentResult.fail(msg, lineNumber) + return false + end if + else + msg = "Input value is not an Array." m.currentResult.fail(msg, lineNumber) return false end if - else - msg = "AssertEmpty: Input value was not an array or a string" - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertNotEmpty - ' * @function - ' * @instance - ' * @description Fail if the item is empty array or string. - ' * @param {Dynamic} item - item to check - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertNotEmpty(item, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if Common.isAssociativeArray(item) or Common.isArray(item) - if item.count() = 0 - msg = "Array is empty." + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertArrayNotCount + ' * @function + ' * @instance + ' * @description Fail if the array items count = expected count. + ' * @param {Dynamic} array - target array + ' * @param {Dynamic} count - An expected array items count. + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertArrayNotCount(array, count, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if Rooibos.Common.isAssociativeArray(array) or Rooibos.Common.isArray(array) + if array.Count() = count + msg = "Array items count = " + Rooibos.Common.asString(count) + "." + m.currentResult.fail(msg, lineNumber) + return false + end if + else + msg = "Input value is not an Array." m.currentResult.fail(msg, lineNumber) return false end if - else if Common.isString(item) - if item = "" - msg = "Input value is empty." + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertEmpty + ' * @function + ' * @instance + ' * @description Fail if the item is not empty array or string. + ' * @param {Dynamic} item - item to check + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertEmpty(item, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if Rooibos.Common.isAssociativeArray(item) or Rooibos.Common.isArray(item) + if item.count() > 0 + msg = "Array is not empty." + m.currentResult.fail(msg, lineNumber) + return false + end if + else if Rooibos.Common.isString(item) + if Rooibos.Common.asString(item) <> "" + msg = "Input value is not empty." + m.currentResult.fail(msg, lineNumber) + return false + end if + else + msg = "AssertEmpty: Input value was not an array or a string" m.currentResult.fail(msg, lineNumber) return false end if - else - msg = "Input value is not a string or array." - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertArrayContainsOnlyValuesOfType - ' * @function - ' * @instance - ' * @description Fail if the array doesn't contains items of specific type only. - ' * @param {Dynamic} array - target array - ' * @param {Dynamic} typeStr - type name - must be String, Array, Boolean, or AssociativeArray - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertArrayContainsOnlyValuesOfType(array, typeStr, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if typeStr <> "String" and typeStr <> "Integer" and typeStr <> "Boolean" and typeStr <> "Array" and typeStr <> "AssociativeArray" - msg = "Type must be Boolean, String, Array, Integer, or AssociativeArray" - m.currentResult.fail(msg, lineNumber) - return false - end if - - if Common.isAssociativeArray(array) or Common.isArray(array) - methodName = "Rooibos_Common_Is" + typeStr - typeCheckFunction = m.getIsTypeFunction(methodName) - if typeCheckFunction <> invalid - for each item in array - if not typeCheckFunction(item) - msg = Common.asString(item) + "is not a '" + typeStr + "' type." - m.currentResult.fail(msg, lineNumber) - return false - end if - end for + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertNotEmpty + ' * @function + ' * @instance + ' * @description Fail if the item is empty array or string. + ' * @param {Dynamic} item - item to check + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertNotEmpty(item, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if Rooibos.Common.isAssociativeArray(item) or Rooibos.Common.isArray(item) + if item.count() = 0 + msg = "Array is empty." + m.currentResult.fail(msg, lineNumber) + return false + end if + else if Rooibos.Common.isString(item) + if item = "" + msg = "Input value is empty." + m.currentResult.fail(msg, lineNumber) + return false + end if else - msg = "could not find comparator for type '" + typeStr + "' type." + msg = "Input value is not a string or array." m.currentResult.fail(msg, lineNumber) return false end if - else - msg = "Input value is not an Array." - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - - function getIsTypeFunction(name) - if name = "Rooibos_Common_IsFunction" - return Common.isFunction - else if name = "Rooibos_Common_IsXmlElement" - return Common.isXmlElement - else if name = "Rooibos_Common_IsInteger" - return Common.isInteger - else if name = "Rooibos_Common_IsBoolean" - return Common.isBoolean - else if name = "Rooibos_Common_IsFloat" - return Common.isFloat - else if name = "Rooibos_Common_IsDouble" - return Common.isDouble - else if name = "Rooibos_Common_IsLongInteger" - return Common.isLongInteger - else if name = "Rooibos_Common_IsNumber" - return Common.isNumber - else if name = "Rooibos_Common_IsList" - return Common.isList - else if name = "Rooibos_Common_IsArray" - return Common.isArray - else if name = "Rooibos_Common_IsAssociativeArray" - return Common.isAssociativeArray - else if name = "Rooibos_Common_IsSGNode" - return Common.isSGNode - else if name = "Rooibos_Common_IsString" - return Common.isString - else if name = "Rooibos_Common_IsDateTime" - return Common.isDateTime - else if name = "Rooibos_Common_IsUndefined" - return Common.isUndefined - else - return invalid - end if - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertType - ' * @function - ' * @instance - ' * @description Asserts that the value is a node of designated type - ' * @param {Dynamic} value - value to check - target node - ' * @param {Dynamic} typeStr - type name - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertType(value, typeStr, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if type(value) <> typeStr - if msg = "" - expr_as_string = Common.asString(value) - msg = expr_as_string + " was not expected type " + typeStr + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertArrayContainsOnlyValuesOfType + ' * @function + ' * @instance + ' * @description Fail if the array doesn't contains items of specific type only. + ' * @param {Dynamic} array - target array + ' * @param {Dynamic} typeStr - type name - must be String, Array, Boolean, or AssociativeArray + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertArrayContainsOnlyValuesOfType(array, typeStr, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if typeStr <> "String" and typeStr <> "Integer" and typeStr <> "Boolean" and typeStr <> "Array" and typeStr <> "AssociativeArray" + msg = "Type must be Boolean, String, Array, Integer, or AssociativeArray" + m.currentResult.fail(msg, lineNumber) + return false end if - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertSubType - ' * @function - ' * @instance - ' * @description Asserts that the value is a node of designated subtype - ' * @param {Dynamic} value - value to check - target node - ' * @param {Dynamic} typeStr - type name - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertSubType(value, typeStr, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if type(value) <> "roSGNode" - if msg = "" - expr_as_string = Common.asString(value) - msg = expr_as_string + " was not a node, so could not match subtype " + typeStr + if Rooibos.Common.isAssociativeArray(array) or Rooibos.Common.isArray(array) + methodName = "Rooibos_Common_Is" + typeStr + typeCheckFunction = m.getIsTypeFunction(methodName) + if typeCheckFunction <> invalid + for each item in array + if not typeCheckFunction(item) + msg = Rooibos.Common.asString(item) + "is not a '" + typeStr + "' type." + m.currentResult.fail(msg, lineNumber) + return false + end if + end for + else + msg = "could not find comparator for type '" + typeStr + "' type." + m.currentResult.fail(msg, lineNumber) + return false + end if + else + msg = "Input value is not an Array." + m.currentResult.fail(msg, lineNumber) + return false end if - m.currentResult.fail(msg, lineNumber) - return false - else if value.subType() <> typeStr - if msg = "" - expr_as_string = Common.asString(value) - msg = expr_as_string + "( type : " + value.subType() + ") was not of subType " + typeStr + m.currentResult.fail("", -1) + return true + end function + + function getIsTypeFunction(name) + if name = "Rooibos_Common_IsFunction" + return Rooibos.Common.isFunction + else if name = "Rooibos_Common_IsXmlElement" + return Rooibos.Common.isXmlElement + else if name = "Rooibos_Common_IsInteger" + return Rooibos.Common.isInteger + else if name = "Rooibos_Common_IsBoolean" + return Rooibos.Common.isBoolean + else if name = "Rooibos_Common_IsFloat" + return Rooibos.Common.isFloat + else if name = "Rooibos_Common_IsDouble" + return Rooibos.Common.isDouble + else if name = "Rooibos_Common_IsLongInteger" + return Rooibos.Common.isLongInteger + else if name = "Rooibos_Common_IsNumber" + return Rooibos.Common.isNumber + else if name = "Rooibos_Common_IsList" + return Rooibos.Common.isList + else if name = "Rooibos_Common_IsArray" + return Rooibos.Common.isArray + else if name = "Rooibos_Common_IsAssociativeArray" + return Rooibos.Common.isAssociativeArray + else if name = "Rooibos_Common_IsSGNode" + return Rooibos.Common.isSGNode + else if name = "Rooibos_Common_IsString" + return Rooibos.Common.isString + else if name = "Rooibos_Common_IsDateTime" + return Rooibos.Common.isDateTime + else if name = "Rooibos_Common_IsUndefined" + return Rooibos.Common.isUndefined + else + return invalid end if - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '++ NEW NODE ASSERTS - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertNodeCount - ' * @function - ' * @instance - ' * @description Asserts that the node contains the desginated number of children - ' * @param {Dynamic} node - target node - ' * @param {Dynamic} count - expected number of child items - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert w, false otherwise - ' */ - function assertNodeCount(node, count, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if type(node) = "roSGNode" - if node.getChildCount() <> count - msg = "node items count <> " + Common.asString(count) + ". Received " + Common.asString(node.getChildCount()) + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertType + ' * @function + ' * @instance + ' * @description Asserts that the value is a node of designated type + ' * @param {Dynamic} value - value to check - target node + ' * @param {Dynamic} typeStr - type name + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertType(value, typeStr, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if type(value) <> typeStr + if msg = "" + expr_as_string = Rooibos.Common.asString(value) + msg = expr_as_string + " was not expected type " + typeStr + end if m.currentResult.fail(msg, lineNumber) return false end if - else - msg = "Input value is not an node." - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertNodeNotCount - ' * @function - ' * @instance - ' * @description Fail if the node items count = expected count. - ' * @param {Dynamic} node - A target node - ' * @param {Dynamic} count - Expected item count - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertNodeNotCount(node, count, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if type(node) = "roSGNode" - if node.getChildCount() = count - msg = "node items count = " + Common.asString(count) + "." + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertSubType + ' * @function + ' * @instance + ' * @description Asserts that the value is a node of designated subtype + ' * @param {Dynamic} value - value to check - target node + ' * @param {Dynamic} typeStr - type name + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertSubType(value, typeStr, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if type(value) <> "roSGNode" + if msg = "" + expr_as_string = Rooibos.Common.asString(value) + msg = expr_as_string + " was not a node, so could not match subtype " + typeStr + end if m.currentResult.fail(msg, lineNumber) return false - end if - else - msg = "Input value is not an node." - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertNodeEmpty - ' * @function - ' * @instance - ' * @description Asserts the node has no children - ' * @param {Dynamic} node - a node to check - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertNodeEmpty(node, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if type(node) = "roSGNode" - if node.getChildCount() > 0 - msg = "node is not empty." + else if value.subType() <> typeStr + if msg = "" + expr_as_string = Rooibos.Common.asString(value) + msg = expr_as_string + "( type : " + value.subType() + ") was not of subType " + typeStr + end if m.currentResult.fail(msg, lineNumber) return false end if - end if - m.currentResult.fail("", -1) - return true - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertNodeNotEmpty - ' * @function - ' * @instance - ' * @description Asserts the node has children - ' * @param {Dynamic} node - a node to check - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertNodeNotEmpty(node, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if type(node) = "roSGNode" - if node.Count() = 0 - msg = "Array is empty." + m.currentResult.fail("", -1) + return true + end function + + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '++ NEW NODE ASSERTS + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertNodeCount + ' * @function + ' * @instance + ' * @description Asserts that the node contains the desginated number of children + ' * @param {Dynamic} node - target node + ' * @param {Dynamic} count - expected number of child items + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert w, false otherwise + ' */ + function assertNodeCount(node, count, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if type(node) = "roSGNode" + if node.getChildCount() <> count + msg = "node items count <> " + Rooibos.Common.asString(count) + ". Received " + Rooibos.Common.asString(node.getChildCount()) + m.currentResult.fail(msg, lineNumber) + return false + end if + else + msg = "Input value is not an node." m.currentResult.fail(msg, lineNumber) return false end if - end if - m.currentResult.fail("", -1) - return true - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertNodeContains - ' * @function - ' * @instance - ' * @description Asserts the node contains the child _value_ - ' * @param {Dynamic} node - a node to check - ' * @param {Dynamic} value - value to check - value to look for - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertNodeContains(node, value, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if type(node) = "roSGNode" - if not Common.nodeContains(node, value) - msg = "Node doesn't have the '" + Common.asString(value) + "' value." + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertNodeNotCount + ' * @function + ' * @instance + ' * @description Fail if the node items count = expected count. + ' * @param {Dynamic} node - A target node + ' * @param {Dynamic} count - Expected item count + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertNodeNotCount(node, count, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if type(node) = "roSGNode" + if node.getChildCount() = count + msg = "node items count = " + Rooibos.Common.asString(count) + "." + m.currentResult.fail(msg, lineNumber) + return false + end if + else + msg = "Input value is not an node." m.currentResult.fail(msg, lineNumber) return false end if - else - msg = "Input value is not an Node." - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertNodeContainsOnly - ' * @function - ' * @instance - ' * @description Asserts the node contains only the child _value_ - ' * @param {Dynamic} node - a node to check - ' * @param {Dynamic} value - value to check - value to look for - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertNodeContainsOnly(node, value, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if type(node) = "roSGNode" - if not Common.nodeContains(node, value) - msg = "Node doesn't have the '" + Common.asString(value) + "' value." + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertNodeEmpty + ' * @function + ' * @instance + ' * @description Asserts the node has no children + ' * @param {Dynamic} node - a node to check + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertNodeEmpty(node, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if type(node) = "roSGNode" + if node.getChildCount() > 0 + msg = "node is not empty." + m.currentResult.fail(msg, lineNumber) + return false + end if + end if + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertNodeNotEmpty + ' * @function + ' * @instance + ' * @description Asserts the node has children + ' * @param {Dynamic} node - a node to check + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertNodeNotEmpty(node, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if type(node) = "roSGNode" + if node.Count() = 0 + msg = "Array is empty." + m.currentResult.fail(msg, lineNumber) + return false + end if + end if + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertNodeContains + ' * @function + ' * @instance + ' * @description Asserts the node contains the child _value_ + ' * @param {Dynamic} node - a node to check + ' * @param {Dynamic} value - value to check - value to look for + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertNodeContains(node, value, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if type(node) = "roSGNode" + if not Rooibos.Common.nodeContains(node, value) + msg = "Node doesn't have the '" + Rooibos.Common.asString(value) + "' value." + m.currentResult.fail(msg, lineNumber) + return false + end if + else + msg = "Input value is not an Node." m.currentResult.fail(msg, lineNumber) return false - else if node.getChildCount() <> 1 - msg = "Node Contains speicified value; but other values as well" + end if + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertNodeContainsOnly + ' * @function + ' * @instance + ' * @description Asserts the node contains only the child _value_ + ' * @param {Dynamic} node - a node to check + ' * @param {Dynamic} value - value to check - value to look for + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertNodeContainsOnly(node, value, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if type(node) = "roSGNode" + if not Rooibos.Common.nodeContains(node, value) + msg = "Node doesn't have the '" + Rooibos.Common.asString(value) + "' value." + m.currentResult.fail(msg, lineNumber) + return false + else if node.getChildCount() <> 1 + msg = "Node Contains speicified value; but other values as well" + m.currentResult.fail(msg, lineNumber) + return false + end if + else + msg = "Input value is not an Node." m.currentResult.fail(msg, lineNumber) return false end if - else - msg = "Input value is not an Node." - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertNodeNotContains - ' * @function - ' * @instance - ' * @description Fail if the node h item. - ' * @param {Dynamic} node - A target node - ' * @param {Dynamic} value - value to check - a node child - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertNodeNotContains(node, value, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if type(node) = "roSGNode" - if Common.nodeContains(node, value) - msg = "Node has the '" + Common.asString(value) + "' value." + m.currentResult.fail("", -1) + return true + end function + + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertNodeNotContains + ' * @function + ' * @instance + ' * @description Fail if the node h item. + ' * @param {Dynamic} node - A target node + ' * @param {Dynamic} value - value to check - a node child + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertNodeNotContains(node, value, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if type(node) = "roSGNode" + if Rooibos.Common.nodeContains(node, value) + msg = "Node has the '" + Rooibos.Common.asString(value) + "' value." + m.currentResult.fail(msg, lineNumber) + return false + end if + else + msg = "Input value is not an Node." m.currentResult.fail(msg, lineNumber) return false end if - else - msg = "Input value is not an Node." - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertNodeContainsFields - ' * @function - ' * @instance - ' * @description Fail if the node doesn't have the item subset. - ' * @param {Dynamic} node - A target node - ' * @param {Dynamic} subset - items to check - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertNodeContainsFields(node, subset, ignoredFields = invalid, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if (type(node) = "roSGNode" and Common.isAssociativeArray(subset)) or (type(node) = "roSGNode" and Common.isArray(subset)) - isAA = Common.isAssociativeArray(subset) - isIgnoredFields = Common.isArray(ignoredFields) - for each key in subset - if key <> "" - if not isIgnoredFields or not Common.arrayContains(ignoredFields, key) - subsetValue = subset[key] - nodeValue = node[key] - if not Common.eqValues(nodeValue, subsetValue) - msg = key + ": Expected '" + Common.asString(subsetValue) + "', got '" + Common.asString(nodeValue) + "'" - m.currentResult.fail(msg, lineNumber) - return false + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertNodeContainsFields + ' * @function + ' * @instance + ' * @description Fail if the node doesn't have the item subset. + ' * @param {Dynamic} node - A target node + ' * @param {Dynamic} subset - items to check + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertNodeContainsFields(node, subset, ignoredFields = invalid, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if (type(node) = "roSGNode" and Rooibos.Common.isAssociativeArray(subset)) or (type(node) = "roSGNode" and Rooibos.Common.isArray(subset)) + isAA = Rooibos.Common.isAssociativeArray(subset) + isIgnoredFields = Rooibos.Common.isArray(ignoredFields) + for each key in subset + if key <> "" + if not isIgnoredFields or not Rooibos.Common.arrayContains(ignoredFields, key) + subsetValue = subset[key] + nodeValue = node[key] + if not Rooibos.Common.eqValues(nodeValue, subsetValue) + msg = key + ": Expected '" + Rooibos.Common.asString(subsetValue) + "', got '" + Rooibos.Common.asString(nodeValue) + "'" + m.currentResult.fail(msg, lineNumber) + return false + end if end if + else + ? "Found empty key!" end if - else - ? "Found empty key!" - end if - end for - else - msg = "Input value is not an Node." - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertNodeNotContainsFields - ' * @function - ' * @instance - ' * @description Fail if the node have the item from subset. - ' * @param {Dynamic} node - A target node - ' * @param {Dynamic} subset - the items to check for - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert w, false otherwise - ' */ - function assertNodeNotContainsFields(node, subset, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if (type(node) = "roSGNode" and Common.isAssociativeArray(subset)) or (type(node) = "roSGNode" and Common.isArray(subset)) - isAA = Common.isAssociativeArray(subset) - for each item in subset - key = invalid - value = item - if isAA - key = item - value = item[key] - end if - if Common.nodeContains(node, value) - msg = "Node has the '" + Common.asString(value) + "' value." - m.currentResult.fail(msg, lineNumber) - return false - end if - end for - else - msg = "Input value is not an Node." - m.currentResult.fail(msg, lineNumber) - return false - end if - m.currentResult.fail("", -1) - return true - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '++ END NODE ASSERTS - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertAAContainsSubset - ' * @function - ' * @instance - ' * @description Asserts the associative array contains the fields contained in subset; while ignoring the fields in the ignoredFields array - ' * @param {Dynamic} array - associative array to check - ' * @param {Dynamic} subset - associative array of values to check for - ' * @param {Dynamic} ignoredFields - array of fieldnames to ignore while comparing - ' * @param {Dynamic} [msg=""] - alternate error message - ' * @returns {boolean} - true if the assert was satisfied, false otherwise - ' */ - function assertAAContainsSubset(array, subset, ignoredFields = invalid, msg = "", lineNumber = -1) as dynamic - if m.currentResult.isFail then return false - if Common.isAssociativeArray(array) and Common.isAssociativeArray(subset) - isAA = Common.isAssociativeArray(subset) - isIgnoredFields = Common.isArray(ignoredFields) - for each key in subset - if key <> "" - if not isIgnoredFields or not Common.arrayContains(ignoredFields, key) - subsetValue = subset[key] - arrayValue = array[key] - if not Common.eqValues(arrayValue, subsetValue) - msg = key + ": Expected '" + Common.asString(subsetValue) + "', got '" + Common.asString(arrayValue) + "'" - m.currentResult.fail(msg, lineNumber) - return false + end for + else + msg = "Input value is not an Node." + m.currentResult.fail(msg, lineNumber) + return false + end if + m.currentResult.fail("", -1) + return true + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertNodeNotContainsFields + ' * @function + ' * @instance + ' * @description Fail if the node have the item from subset. + ' * @param {Dynamic} node - A target node + ' * @param {Dynamic} subset - the items to check for + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert w, false otherwise + ' */ + function assertNodeNotContainsFields(node, subset, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if (type(node) = "roSGNode" and Rooibos.Common.isAssociativeArray(subset)) or (type(node) = "roSGNode" and Rooibos.Common.isArray(subset)) + isAA = Rooibos.Common.isAssociativeArray(subset) + for each item in subset + key = invalid + value = item + if isAA + key = item + value = item[key] + end if + if Rooibos.Common.nodeContains(node, value) + msg = "Node has the '" + Rooibos.Common.asString(value) + "' value." + m.currentResult.fail(msg, lineNumber) + return false + end if + end for + else + msg = "Input value is not an Node." + m.currentResult.fail(msg, lineNumber) + return false + end if + m.currentResult.fail("", -1) + return true + end function + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '++ END NODE ASSERTS + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertAAContainsSubset + ' * @function + ' * @instance + ' * @description Asserts the associative array contains the fields contained in subset; while ignoring the fields in the ignoredFields array + ' * @param {Dynamic} array - associative array to check + ' * @param {Dynamic} subset - associative array of values to check for + ' * @param {Dynamic} ignoredFields - array of fieldnames to ignore while comparing + ' * @param {Dynamic} [msg=""] - alternate error message + ' * @returns {boolean} - true if the assert was satisfied, false otherwise + ' */ + function assertAAContainsSubset(array, subset, ignoredFields = invalid, msg = "", lineNumber = -1) as dynamic + if m.currentResult.isFail then return false + if Rooibos.Common.isAssociativeArray(array) and Rooibos.Common.isAssociativeArray(subset) + isAA = Rooibos.Common.isAssociativeArray(subset) + isIgnoredFields = Rooibos.Common.isArray(ignoredFields) + for each key in subset + if key <> "" + if not isIgnoredFields or not Rooibos.Common.arrayContains(ignoredFields, key) + subsetValue = subset[key] + arrayValue = array[key] + if not Rooibos.Common.eqValues(arrayValue, subsetValue) + msg = key + ": Expected '" + Rooibos.Common.asString(subsetValue) + "', got '" + Rooibos.Common.asString(arrayValue) + "'" + m.currentResult.fail(msg, lineNumber) + return false + end if end if + else + ? "Found empty key!" end if - else - ? "Found empty key!" - end if - end for - else - msg = "Input values are not an Associative Array." - - return false - end if - m.currentResult.fail("", -1) - return true - end function - - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '++ Stubbing helpers - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + end for + else + msg = "Input values are not an Associative Array." - ' /** - ' * @memberof module:BaseTestSuite - ' * @name stub - ' * @function - ' * @instance - ' * @description Creates a stub to replace a real method with - ' * @param {Dynamic} target - object on which the method to be stubbed is found - ' * @param {Dynamic} methodName - name of method to stub - ' * @param {Dynamic} [returnValue=invalid] - value that the stub method will return when invoked - ' * @param {boolean} [allowNonExistingMethods=false] - if true, then rooibos will only warn if the method did not exist prior to faking - ' * @returns {Object} - stub that was wired into the real method - ' */ - function stub(target, methodName, returnValue = invalid, allowNonExistingMethods = false) as object - if type(target) <> "roAssociativeArray" - m.fail("could not create Stub provided target was null") - return {} - end if - - if m.stubs = invalid - m.__stubId = -1 - m.stubs = {} - end if - m.__stubId++ - - if m.__stubId > 5 - ? "ERROR ONLY 6 STUBS PER TEST ARE SUPPORTED!!" - return invalid - end if - - id = stri(m.__stubId).trim() - - fake = m.createFake(id, target, methodName, 1, invalid, returnValue) - m.stubs[id] = fake - allowNonExisting = m.allowNonExistingMethodsOnMocks = true or allowNonExistingMethods - isMethodPresent = type(target[methodName]) = "Function" or type(target[methodName]) = "roFunction" - if isMethodPresent or allowNonExisting - target[methodName] = m["StubCallback" + id] - target.__stubs = m.stubs - - if not isMethodPresent - ? "WARNING - stubbing call " ; methodName; " which did not exist on target object" + return false + end if + m.currentResult.fail("", -1) + return true + end function + + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '++ Stubbing helpers + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name stub + ' * @function + ' * @instance + ' * @description Creates a stub to replace a real method with + ' * @param {Dynamic} target - object on which the method to be stubbed is found + ' * @param {Dynamic} methodName - name of method to stub + ' * @param {Dynamic} [returnValue=invalid] - value that the stub method will return when invoked + ' * @param {boolean} [allowNonExistingMethods=false] - if true, then rooibos will only warn if the method did not exist prior to faking + ' * @returns {Object} - stub that was wired into the real method + ' */ + function stub(target, methodName, returnValue = invalid, allowNonExistingMethods = false) as object + if type(target) <> "roAssociativeArray" + m.fail("could not create Stub provided target was null") + return {} end if - else - ? "ERROR - could not create Stub : method not found "; target ; "." ; methodName - end if - - return fake - end function - ' /** - ' * @memberof module:BaseTestSuite - ' * @name expectOnce - ' * @function - ' * @instance - ' * @description Creates a stub to replace a real method with, which the framework will track. If it was invoked the wrong number of times, or with wrong arguments, it will result in test failure - ' * @param {Dynamic} target - object on which the method to be stubbed is found - ' * @param {Dynamic} methodName - name of method to stub - ' * @param {Dynamic} [expectedArgs=invalid] - array containing the arguments we expect the method to be invoked with - ' * @param {Dynamic} [returnValue=invalid] - value that the stub method will return when invoked - ' * @param {boolean} [allowNonExistingMethods=false] - if true, then rooibos will only warn if the method did not exist prior to faking - ' * @returns {Object} - mock that was wired into the real method - ' */ - function expectOnce(target, methodName, expectedArgs = invalid, returnValue = invalid, allowNonExistingMethods = false) as object - return m.mock(target, methodName, 1, expectedArgs, returnValue, allowNonExistingMethods) - end function + if m.stubs = invalid + m.__stubId = -1 + m.stubs = {} + end if + m.__stubId++ - function expectOnceWLN(lineNumber, target, methodName, expectedArgs = invalid, returnValue = invalid, allowNonExistingMethods = false) as object - return m.mock(target, methodName, 1, expectedArgs, returnValue, allowNonExistingMethods, lineNumber) - end function + if m.__stubId > 5 + ? "ERROR ONLY 6 STUBS PER TEST ARE SUPPORTED!!" + return invalid + end if - ' /** - ' * @memberof module:BaseTestSuite - ' * @name expectOnceOrNone - ' * @function - ' * @instance - ' * @description Toggles between expectOnce and expectNone, to allow for easy paremeterized expect behaviour - ' * @param {Dynamic} target - object on which the method to be stubbed is found - ' * @param {Dynamic} methodName - name of method to stub - ' * @param {Dynamic} isExpected - if true, then this is the same as expectOnce, if false, then this is the same as expectNone - ' * @param {Dynamic} [expectedArgs=invalid] - array containing the arguments we expect the method to be invoked with - ' * @param {Dynamic} [returnValue=invalid] - value that the stub method will return when invoked - ' * @param {boolean} [allowNonExistingMethods=false] - if true, then rooibos will only warn if the method did not exist prior to faking - ' * @returns {Object} - mock that was wired into the real method - ' */ - function expectOnceOrNone(target, methodName, isExpected, expectedArgs = invalid, returnValue = invalid, allowNonExistingMethods = false) as object - if isExpected - return m.expectOnce(target, methodName, expectedArgs, returnValue, allowNonExistingMethods) - else - return m.expectNone(target, methodName, allowNonExistingMethods) - end if - end function - - function expectOnceOrNoneWLN(lineNumber, target, methodName, isExpected, expectedArgs = invalid, returnValue = invalid, allowNonExistingMethods = false) as object - if isExpected - return m.expectOnceWLN(lineNumber, target, methodName, expectedArgs, returnValue, allowNonExistingMethods) - else - return m.expectNoneWLN(lineNumber, target, methodName, allowNonExistingMethods) - end if - end function + id = stri(m.__stubId).trim() + fake = m.createFake(id, target, methodName, 1, invalid, returnValue) + m.stubs[id] = fake + allowNonExisting = m.allowNonExistingMethodsOnMocks = true or allowNonExistingMethods + isMethodPresent = type(target[methodName]) = "Function" or type(target[methodName]) = "roFunction" + if isMethodPresent or allowNonExisting + target[methodName] = m["StubCallback" + id] + target.__stubs = m.stubs - ' /** - ' * @memberof module:BaseTestSuite - ' * @name expectNone - ' * @function - ' * @instance - ' * @description Creates a stub to replace a real method with, which the framework will track. If it was invoked, it will result in test failure - ' * @param {Dynamic} target - object on which the method to be stubbed is found - ' * @param {Dynamic} methodName - name of method to stub - ' * @param {boolean} [allowNonExistingMethods=false] - if true, then rooibos will only warn if the method did not exist prior to faking - ' * @returns {Object} - mock that was wired into the real method - ' */ - function expectNone(target, methodName, allowNonExistingMethods = false) as object - return m.mock(target, methodName, 0, invalid, invalid, allowNonExistingMethods) - end function + if not isMethodPresent + ? "WARNING - stubbing call " ; methodName; " which did not exist on target object" + end if + else + ? "ERROR - could not create Stub : method not found "; target ; "." ; methodName + end if - function expectNoneWLN(lineNumber, target, methodName, allowNonExistingMethods = false) as object - return m.mock(target, methodName, 0, invalid, invalid, allowNonExistingMethods, lineNumber) - end function + return fake + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name expectOnce + ' * @function + ' * @instance + ' * @description Creates a stub to replace a real method with, which the framework will track. If it was invoked the wrong number of times, or with wrong arguments, it will result in test failure + ' * @param {Dynamic} target - object on which the method to be stubbed is found + ' * @param {Dynamic} methodName - name of method to stub + ' * @param {Dynamic} [expectedArgs=invalid] - array containing the arguments we expect the method to be invoked with + ' * @param {Dynamic} [returnValue=invalid] - value that the stub method will return when invoked + ' * @param {boolean} [allowNonExistingMethods=false] - if true, then rooibos will only warn if the method did not exist prior to faking + ' * @returns {Object} - mock that was wired into the real method + ' */ + function expectOnce(target, methodName, expectedArgs = invalid, returnValue = invalid, allowNonExistingMethods = false) as object + return m.mock(target, methodName, 1, expectedArgs, returnValue, allowNonExistingMethods) + end function + + function expectOnceWLN(lineNumber, target, methodName, expectedArgs = invalid, returnValue = invalid, allowNonExistingMethods = false) as object + return m.mock(target, methodName, 1, expectedArgs, returnValue, allowNonExistingMethods, lineNumber) + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name expectOnceOrNone + ' * @function + ' * @instance + ' * @description Toggles between expectOnce and expectNone, to allow for easy paremeterized expect behaviour + ' * @param {Dynamic} target - object on which the method to be stubbed is found + ' * @param {Dynamic} methodName - name of method to stub + ' * @param {Dynamic} isExpected - if true, then this is the same as expectOnce, if false, then this is the same as expectNone + ' * @param {Dynamic} [expectedArgs=invalid] - array containing the arguments we expect the method to be invoked with + ' * @param {Dynamic} [returnValue=invalid] - value that the stub method will return when invoked + ' * @param {boolean} [allowNonExistingMethods=false] - if true, then rooibos will only warn if the method did not exist prior to faking + ' * @returns {Object} - mock that was wired into the real method + ' */ + function expectOnceOrNone(target, methodName, isExpected, expectedArgs = invalid, returnValue = invalid, allowNonExistingMethods = false) as object + if isExpected + return m.expectOnce(target, methodName, expectedArgs, returnValue, allowNonExistingMethods) + else + return m.expectNone(target, methodName, allowNonExistingMethods) + end if + end function - ' /** - ' * @memberof module:BaseTestSuite - ' * @name expect - ' * @function - ' * @instance - ' * @description Creates a stub to replace a real method with, which the framework will track. If it was invoked the wrong number of times, or with wrong arguments, it will result in test failure - ' * @param {Dynamic} target - object on which the method to be stubbed is found - ' * @param {Dynamic} methodName - name of method to stub - ' * @param {Dynamic} [expectedInvocations=1] - number of invocations we expect - ' * @param {Dynamic} [expectedArgs=invalid] - array containing the arguments we expect the method to be invoked with - ' * @param {Dynamic} [returnValue=invalid] - value that the stub method will return when invoked - ' * @param {boolean} [allowNonExistingMethods=false] - if true, then rooibos will only warn if the method did not exist prior to faking - ' * @returns {Object} - mock that was wired into the real method - ' */ - function expect(target, methodName, expectedInvocations = 1, expectedArgs = invalid, returnValue = invalid, allowNonExistingMethods = false) as object - return m.mock(target, methodName, expectedInvocations, expectedArgs, returnValue, allowNonExistingMethods) - end function + function expectOnceOrNoneWLN(lineNumber, target, methodName, isExpected, expectedArgs = invalid, returnValue = invalid, allowNonExistingMethods = false) as object + if isExpected + return m.expectOnceWLN(lineNumber, target, methodName, expectedArgs, returnValue, allowNonExistingMethods) + else + return m.expectNoneWLN(lineNumber, target, methodName, allowNonExistingMethods) + end if + end function + + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name expectNone + ' * @function + ' * @instance + ' * @description Creates a stub to replace a real method with, which the framework will track. If it was invoked, it will result in test failure + ' * @param {Dynamic} target - object on which the method to be stubbed is found + ' * @param {Dynamic} methodName - name of method to stub + ' * @param {boolean} [allowNonExistingMethods=false] - if true, then rooibos will only warn if the method did not exist prior to faking + ' * @returns {Object} - mock that was wired into the real method + ' */ + function expectNone(target, methodName, allowNonExistingMethods = false) as object + return m.mock(target, methodName, 0, invalid, invalid, allowNonExistingMethods) + end function + + function expectNoneWLN(lineNumber, target, methodName, allowNonExistingMethods = false) as object + return m.mock(target, methodName, 0, invalid, invalid, allowNonExistingMethods, lineNumber) + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name expect + ' * @function + ' * @instance + ' * @description Creates a stub to replace a real method with, which the framework will track. If it was invoked the wrong number of times, or with wrong arguments, it will result in test failure + ' * @param {Dynamic} target - object on which the method to be stubbed is found + ' * @param {Dynamic} methodName - name of method to stub + ' * @param {Dynamic} [expectedInvocations=1] - number of invocations we expect + ' * @param {Dynamic} [expectedArgs=invalid] - array containing the arguments we expect the method to be invoked with + ' * @param {Dynamic} [returnValue=invalid] - value that the stub method will return when invoked + ' * @param {boolean} [allowNonExistingMethods=false] - if true, then rooibos will only warn if the method did not exist prior to faking + ' * @returns {Object} - mock that was wired into the real method + ' */ + function expect(target, methodName, expectedInvocations = 1, expectedArgs = invalid, returnValue = invalid, allowNonExistingMethods = false) as object + return m.mock(target, methodName, expectedInvocations, expectedArgs, returnValue, allowNonExistingMethods) + end function + + function expectWLN(lineNumber, target, methodName, expectedInvocations = 1, expectedArgs = invalid, returnValue = invalid, allowNonExistingMethods = false) as object + return m.mock(target, methodName, expectedInvocations, expectedArgs, returnValue, allowNonExistingMethods, lineNumber) + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name mock + ' * @function + ' * @instance + ' * @description Creates a stub to replace a real method with, which the framework will track. If it was invoked the wrong number of times, or with wrong arguments, it will result in test failure + ' * @param {Dynamic} target - object on which the method to be stubbed is found + ' * @param {Dynamic} methodName - name of method to stub + ' * @param {Dynamic} expectedInvocations - number of invocations we expect + ' * @param {Dynamic} [expectedArgs=invalid] - array containing the arguments we expect the method to be invoked with + ' * @param {Dynamic} [returnValue=invalid] - value that the stub method will return when invoked + ' * @param {boolean} [allowNonExistingMethods=false] - if true, then rooibos will only warn if the method did not exist prior to faking + ' * @returns {Object} - mock that was wired into the real method + ' */ + function mock(target, methodName, expectedInvocations = 1, expectedArgs = invalid, returnValue = invalid, allowNonExistingMethods = false, lineNumber = -1) as object + 'check params + if not Rooibos.Common.isAssociativeArray(target) + methodName = "" + m.mockFail(lineNumber, "", "mock args: target was not an AA") + else if not Rooibos.Common.isString(methodName) + methodName = "" + m.mockFail(lineNumber, "", "mock args: methodName was not a string") + else if not Rooibos.Common.isNumber(expectedInvocations) + m.mockFail(lineNumber, methodName, "mock args: expectedInvocations was not an int") + else if not Rooibos.Common.isArray(expectedArgs) and Rooibos.Common.isValid(expectedArgs) + m.mockFail(lineNumber, methodName, "mock args: expectedArgs was not invalid or an array of args") + else if Rooibos.Common.isUndefined(expectedArgs) + m.mockFail(lineNumber, methodName, "mock args: expectedArgs undefined") + else if Rooibos.Common.isUndefined(returnValue) + m.mockFail(lineNumber, methodName, "mock args: returnValue undefined") + end if - function expectWLN(lineNumber, target, methodName, expectedInvocations = 1, expectedArgs = invalid, returnValue = invalid, allowNonExistingMethods = false) as object - return m.mock(target, methodName, expectedInvocations, expectedArgs, returnValue, allowNonExistingMethods, lineNumber) - end function + if m.currentResult.isFail + ? "ERROR! Cannot create MOCK. method " ; methodName ;" " str(lineNumber) ; " "; m.currentResult.message + return {} + end if - ' /** - ' * @memberof module:BaseTestSuite - ' * @name mock - ' * @function - ' * @instance - ' * @description Creates a stub to replace a real method with, which the framework will track. If it was invoked the wrong number of times, or with wrong arguments, it will result in test failure - ' * @param {Dynamic} target - object on which the method to be stubbed is found - ' * @param {Dynamic} methodName - name of method to stub - ' * @param {Dynamic} expectedInvocations - number of invocations we expect - ' * @param {Dynamic} [expectedArgs=invalid] - array containing the arguments we expect the method to be invoked with - ' * @param {Dynamic} [returnValue=invalid] - value that the stub method will return when invoked - ' * @param {boolean} [allowNonExistingMethods=false] - if true, then rooibos will only warn if the method did not exist prior to faking - ' * @returns {Object} - mock that was wired into the real method - ' */ - function mock(target, methodName, expectedInvocations = 1, expectedArgs = invalid, returnValue = invalid, allowNonExistingMethods = false, lineNumber = -1) as object - 'check params - if not Common.isAssociativeArray(target) - methodName = "" - m.mockFail(lineNumber, "", "mock args: target was not an AA") - else if not Common.isString(methodName) - methodName = "" - m.mockFail(lineNumber, "", "mock args: methodName was not a string") - else if not Common.isNumber(expectedInvocations) - m.mockFail(lineNumber, methodName, "mock args: expectedInvocations was not an int") - else if not Common.isArray(expectedArgs) and Common.isValid(expectedArgs) - m.mockFail(lineNumber, methodName, "mock args: expectedArgs was not invalid or an array of args") - else if Common.isUndefined(expectedArgs) - m.mockFail(lineNumber, methodName, "mock args: expectedArgs undefined") - else if Common.isUndefined(returnValue) - m.mockFail(lineNumber, methodName, "mock args: returnValue undefined") - end if - - if m.currentResult.isFail - ? "ERROR! Cannot create MOCK. method " ; methodName ;" " str(lineNumber) ; " "; m.currentResult.message - return {} - end if - - if m.mocks = invalid - m.__mockId = -1 - m.__mockTargetId = -1 - m.mocks = {} - end if - - fake = invalid - if not target.doesExist("__rooibosTargetId") - m.__mockTargetId++ - target["__rooibosTargetId"] = m.__mockTargetId - end if - 'ascertain if mock already exists - for i = 0 to m.__mockId - id = stri(i).trim() - mock = m.mocks[id] - if mock <> invalid and mock.methodName = methodName and mock.target.__rooibosTargetId = target.__rooibosTargetId - fake = mock - fake.lineNumbers.push(lineNumber) - exit for + if m.mocks = invalid + m.__mockId = -1 + m.__mockTargetId = -1 + m.mocks = {} end if - end for - if fake = invalid - m.__mockId++ - id = stri(m.__mockId).trim() - if m.__mockId > 25 - ? "ERROR ONLY 25 MOCKS PER TEST ARE SUPPORTED!! you're on # " ; m.__mockId - ? " Method was " ; methodName - return invalid + + fake = invalid + if not target.doesExist("__rooibosTargetId") + m.__mockTargetId++ + target["__rooibosTargetId"] = m.__mockTargetId end if + 'ascertain if mock already exists + for i = 0 to m.__mockId + id = stri(i).trim() + mock = m.mocks[id] + if mock <> invalid and mock.methodName = methodName and mock.target.__rooibosTargetId = target.__rooibosTargetId + fake = mock + fake.lineNumbers.push(lineNumber) + exit for + end if + end for + if fake = invalid + m.__mockId++ + id = stri(m.__mockId).trim() + if m.__mockId > 25 + ? "ERROR ONLY 25 MOCKS PER TEST ARE SUPPORTED!! you're on # " ; m.__mockId + ? " Method was " ; methodName + return invalid + end if - fake = m.createFake(id, target, methodName, expectedInvocations, expectedArgs, returnValue, lineNumber) - m.mocks[id] = fake 'this will bind it to m - allowNonExisting = m.allowNonExistingMethodsOnMocks = true or allowNonExistingMethods - isMethodPresent = type(target[methodName]) = "Function" or type(target[methodName]) = "roFunction" - if isMethodPresent or allowNonExisting - target[methodName] = m["MockCallback" + id] - target.__mocks = m.mocks + fake = m.createFake(id, target, methodName, expectedInvocations, expectedArgs, returnValue, lineNumber) + m.mocks[id] = fake 'this will bind it to m + allowNonExisting = m.allowNonExistingMethodsOnMocks = true or allowNonExistingMethods + isMethodPresent = type(target[methodName]) = "Function" or type(target[methodName]) = "roFunction" + if isMethodPresent or allowNonExisting + target[methodName] = m["MockCallback" + id] + target.__mocks = m.mocks - if not isMethodPresent - ? "WARNING - mocking call " ; methodName; " which did not exist on target object" + if not isMethodPresent + ? "WARNING - mocking call " ; methodName; " which did not exist on target object" + end if + else + ? "ERROR - could not create Mock : method not found "; target ; "." ; methodName end if else - ? "ERROR - could not create Mock : method not found "; target ; "." ; methodName + m.combineFakes(fake, m.createFake(id, target, methodName, expectedInvocations, expectedArgs, returnValue, lineNumber)) end if - else - m.combineFakes(fake, m.createFake(id, target, methodName, expectedInvocations, expectedArgs, returnValue, lineNumber)) - end if - return fake - end function - - ' /** - ' * @memberof module:BaseTestSuite - ' * @name createFake - ' * @function - ' * @instance - ' * @description Creates a stub to replace a real method with. This is used internally. - ' * @param {Dynamic} target - object on which the method to be stubbed is found - ' * @param {Dynamic} methodName - name of method to stub - ' * @param {Dynamic} [expectedInvocations=1] - number of invocations we expect - ' * @param {Dynamic} [expectedArgs=invalid] - array containing the arguments we expect the method to be invoked with - ' * @param {Dynamic} [returnValue=invalid] - value that the stub method will return when invoked - ' * @returns {Object} - stub that was wired into the real method - ' */ - function createFake(id, target, methodName, expectedInvocations = 1, expectedArgs = invalid, returnValue = invalid, lineNumber = -1) as object - expectedArgsValues = [] - hasArgs = Common.isArray(expectedArgs) - if hasArgs - defaultValue = m.invalidValue - else - defaultValue = m.ignoreValue - expectedArgs = [] - end if - lineNumbers = [lineNumber] - - for i = 0 to 9 - if hasArgs and expectedArgs.count() > i - 'guard against bad values - value = expectedArgs[i] - if not Common.isUndefined(value) - if Common.isAssociativeArray(value) and Common.isValid(value.matcher) - if not Common.isFunction(value.matcher) - ? "[ERROR] you have specified a matching function; but it is not in scope!" - expectedArgsValues.push("#ERR-OUT_OF_SCOPE_MATCHER!") + return fake + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name createFake + ' * @function + ' * @instance + ' * @description Creates a stub to replace a real method with. This is used internally. + ' * @param {Dynamic} target - object on which the method to be stubbed is found + ' * @param {Dynamic} methodName - name of method to stub + ' * @param {Dynamic} [expectedInvocations=1] - number of invocations we expect + ' * @param {Dynamic} [expectedArgs=invalid] - array containing the arguments we expect the method to be invoked with + ' * @param {Dynamic} [returnValue=invalid] - value that the stub method will return when invoked + ' * @returns {Object} - stub that was wired into the real method + ' */ + function createFake(id, target, methodName, expectedInvocations = 1, expectedArgs = invalid, returnValue = invalid, lineNumber = -1) as object + expectedArgsValues = [] + hasArgs = Rooibos.Common.isArray(expectedArgs) + if hasArgs + defaultValue = m.invalidValue + else + defaultValue = m.ignoreValue + expectedArgs = [] + end if + lineNumbers = [lineNumber] + + for i = 0 to 9 + if hasArgs and expectedArgs.count() > i + 'guard against bad values + value = expectedArgs[i] + if not Rooibos.Common.isUndefined(value) + if Rooibos.Common.isAssociativeArray(value) and Rooibos.Common.isValid(value.matcher) + if not Rooibos.Common.isFunction(value.matcher) + ? "[ERROR] you have specified a matching function; but it is not in scope!" + expectedArgsValues.push("#ERR-OUT_OF_SCOPE_MATCHER!") + else + expectedArgsValues.push(expectedArgs[i]) + end if else expectedArgsValues.push(expectedArgs[i]) end if else - expectedArgsValues.push(expectedArgs[i]) + expectedArgsValues.push("#ERR-UNDEFINED!") end if else - expectedArgsValues.push("#ERR-UNDEFINED!") + expectedArgsValues.push(defaultValue) end if - else - expectedArgsValues.push(defaultValue) - end if - end for - fake = { - id: id, - target: target, - methodName: methodName, - returnValue: returnValue, - lineNumbers: lineNumbers, - isCalled: false, - invocations: 0, - invokedArgs: [invalid, invalid, invalid, invalid, invalid, invalid, invalid, invalid, invalid], - expectedArgs: expectedArgsValues, - expectedInvocations: expectedInvocations, - callback: function(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - ' ? "FAKE CALLBACK CALLED FOR " ; m.methodName - if m.allInvokedArgs = invalid - m.allInvokedArgs = [] - end if - m.invokedArgs = [arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9] - m.allInvokedArgs.push ([arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9]) - m.isCalled = true - m.invocations++ + end for + fake = { + id: id, + target: target, + methodName: methodName, + returnValue: returnValue, + lineNumbers: lineNumbers, + isCalled: false, + invocations: 0, + invokedArgs: [invalid, invalid, invalid, invalid, invalid, invalid, invalid, invalid, invalid], + expectedArgs: expectedArgsValues, + expectedInvocations: expectedInvocations, + callback: function(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + ' ? "FAKE CALLBACK CALLED FOR " ; m.methodName + if m.allInvokedArgs = invalid + m.allInvokedArgs = [] + end if + m.invokedArgs = [arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9] + m.allInvokedArgs.push ([arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9]) + m.isCalled = true + m.invocations++ - if type(m.returnValue) = "roAssociativeArray" and m.returnValue.doesExist("multiResult") - returnValues = m.returnValue["multiResult"] - returnIndex = m.invocations - 1 + if type(m.returnValue) = "roAssociativeArray" and m.returnValue.doesExist("multiResult") + returnValues = m.returnValue["multiResult"] + returnIndex = m.invocations - 1 - if type(returnValues) = "roArray" and returnValues.count() > 0 + if type(returnValues) = "roArray" and returnValues.count() > 0 - if returnValues.count() <= m.invocations - returnIndex = returnValues.count() - 1 - print "Multi return values all used up - repeating last value" + if returnValues.count() <= m.invocations + returnIndex = returnValues.count() - 1 + print "Multi return values all used up - repeating last value" + end if + return returnValues[returnIndex] + else + ? "Multi return value was specified; but no array of results were found" + return invalid end if - return returnValues[returnIndex] else - ? "Multi return value was specified; but no array of results were found" - return invalid + return m.returnValue end if - else - return m.returnValue - end if - end function - } - return fake - end function - - function combineFakes(fake, otherFake) - 'add on the expected invoked args - if type(fake.expectedArgs) <> "roAssociativeArray" or not fake.expectedArgs.doesExist("multiInvoke") - currentExpectedArgsArgs = fake.expectedArgs - fake.expectedArgs = { - "multiInvoke": [currentExpectedArgsArgs] - } - end if - fake.expectedArgs.multiInvoke.push(otherFake.expectedArgs) - - 'add on the expected return values - if type(fake.returnValue) <> "roAssociativeArray" or not fake.returnValue.doesExist("multiResult") - currentReturnValue = fake.returnValue - fake.returnValue = { - "multiResult": [currentReturnValue] + end function } - end if - fake.returnValue.multiResult.push(otherFake.returnValue) - fake.lineNumbers.push(lineNumber) - fake.expectedInvocations++ - end function - ' /** - ' * @memberof module:BaseTestSuite - ' * @name assertMocks - ' * @function - ' * @instance - ' * @description Will check all mocks that have been created to ensure they were invoked the expected amount of times, with the expected args. - ' */ - function assertMocks() as void - if m.__mockId = invalid or not Common.isAssociativeArray(m.mocks) - return - end if - - lastId = int(m.__mockId) - for each id in m.mocks - mock = m.mocks[id] - methodName = mock.methodName - if mock.expectedInvocations <> mock.invocations - m.mockFail(mock.lineNumbers[0], methodName, "Wrong number of calls. (" + stri(mock.invocations).trim() + " / " + stri(mock.expectedInvocations).trim() + ")") - m.cleanMocks() + return fake + end function + + function combineFakes(fake, otherFake) + 'add on the expected invoked args + if type(fake.expectedArgs) <> "roAssociativeArray" or not fake.expectedArgs.doesExist("multiInvoke") + currentExpectedArgsArgs = fake.expectedArgs + fake.expectedArgs = { + "multiInvoke": [currentExpectedArgsArgs] + } + end if + fake.expectedArgs.multiInvoke.push(otherFake.expectedArgs) + + 'add on the expected return values + if type(fake.returnValue) <> "roAssociativeArray" or not fake.returnValue.doesExist("multiResult") + currentReturnValue = fake.returnValue + fake.returnValue = { + "multiResult": [currentReturnValue] + } + end if + fake.returnValue.multiResult.push(otherFake.returnValue) + fake.lineNumbers.push(lineNumber) + fake.expectedInvocations++ + end function + ' /** + ' * @memberof module:BaseTestSuite + ' * @name assertMocks + ' * @function + ' * @instance + ' * @description Will check all mocks that have been created to ensure they were invoked the expected amount of times, with the expected args. + ' */ + function assertMocks() as void + if m.__mockId = invalid or not Rooibos.Common.isAssociativeArray(m.mocks) return - else if mock.expectedInvocations > 0 and (Common.isArray(mock.expectedArgs) or (type(mock.expectedArgs) = "roAssociativeArray" and Common.isArray(mock.expectedArgs.multiInvoke))) - isMultiArgsSupported = type(mock.expectedArgs) = "roAssociativeArray" and Common.isArray(mock.expectedArgs.multiInvoke) + end if - for invocationIndex = 0 to mock.invocations - 1 - invokedArgs = mock.allInvokedArgs[invocationIndex] - if isMultiArgsSupported - expectedArgs = mock.expectedArgs.multiInvoke[invocationIndex] - else - expectedArgs = mock.expectedArgs - end if - for i = 0 to expectedArgs.count() - 1 - value = invokedArgs[i] - expected = expectedArgs[i] - didNotExpectArg = Common.isString(expected) and expected = m.invalidValue - if didNotExpectArg - expected = invalid + lastId = int(m.__mockId) + for each id in m.mocks + mock = m.mocks[id] + methodName = mock.methodName + if mock.expectedInvocations <> mock.invocations + m.mockFail(mock.lineNumbers[0], methodName, "Wrong number of calls. (" + stri(mock.invocations).trim() + " / " + stri(mock.expectedInvocations).trim() + ")") + m.cleanMocks() + return + else if mock.expectedInvocations > 0 and (Rooibos.Common.isArray(mock.expectedArgs) or (type(mock.expectedArgs) = "roAssociativeArray" and Rooibos.Common.isArray(mock.expectedArgs.multiInvoke))) + isMultiArgsSupported = type(mock.expectedArgs) = "roAssociativeArray" and Rooibos.Common.isArray(mock.expectedArgs.multiInvoke) + + for invocationIndex = 0 to mock.invocations - 1 + invokedArgs = mock.allInvokedArgs[invocationIndex] + if isMultiArgsSupported + expectedArgs = mock.expectedArgs.multiInvoke[invocationIndex] + else + expectedArgs = mock.expectedArgs end if + for i = 0 to expectedArgs.count() - 1 + value = invokedArgs[i] + expected = expectedArgs[i] + didNotExpectArg = Rooibos.Common.isString(expected) and expected = m.invalidValue + if didNotExpectArg + expected = invalid + end if - isUsingMatcher = Common.isAssociativeArray(expected) and Common.isFunction(expected.matcher) + isUsingMatcher = Rooibos.Common.isAssociativeArray(expected) and Rooibos.Common.isFunction(expected.matcher) - if isUsingMatcher - if not expected.matcher(value) - m.mockFail(mock.lineNumbers[invocationIndex], methodName, "on Invocation #" + stri(invocationIndex).trim() + ", expected arg #" + stri(i).trim() + " to match matching function '" + Common.asString(expected.matcher) + "' got '" + Common.asString(value) + "')") - m.cleanMocks() - end if - else - if not (Common.isString(expected) and expected = m.ignoreValue) and not Common.eqValues(value, expected) - if expected = invalid - expected = "[INVALID]" + if isUsingMatcher + if not expected.matcher(value) + m.mockFail(mock.lineNumbers[invocationIndex], methodName, "on Invocation #" + stri(invocationIndex).trim() + ", expected arg #" + stri(i).trim() + " to match matching function '" + Rooibos.Common.asString(expected.matcher) + "' got '" + Rooibos.Common.asString(value) + "')") + m.cleanMocks() + end if + else + if not (Rooibos.Common.isString(expected) and expected = m.ignoreValue) and not Rooibos.Common.eqValues(value, expected) + if expected = invalid + expected = "[INVALID]" + end if + + m.mockFail(mock.lineNumbers[invocationIndex], methodName, "on Invocation #" + stri(invocationIndex).trim() + ", expected arg #" + stri(i).trim() + " to be '" + Rooibos.Common.asString(expected) + "' got '" + Rooibos.Common.asString(value) + "')") + m.cleanMocks() + return end if - - m.mockFail(mock.lineNumbers[invocationIndex], methodName, "on Invocation #" + stri(invocationIndex).trim() + ", expected arg #" + stri(i).trim() + " to be '" + Common.asString(expected) + "' got '" + Common.asString(value) + "')") - m.cleanMocks() - return end if - end if + end for end for - end for - end if - end for - - m.cleanMocks() - end function + end if + end for - ' /** - ' * @memberof module:BaseTestSuite - ' * @name cleanMocks - ' * @function - ' * @instance - ' * @description Cleans up all tracking data associated with mocks - ' */ - function cleanMocks() as void - if m.mocks = invalid then return - for each id in m.mocks - mock = m.mocks[id] - mock.target.__mocks = invalid - end for - m.mocks = invalid - end function + m.cleanMocks() + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name cleanMocks + ' * @function + ' * @instance + ' * @description Cleans up all tracking data associated with mocks + ' */ + function cleanMocks() as void + if m.mocks = invalid then return + for each id in m.mocks + mock = m.mocks[id] + mock.target.__mocks = invalid + end for + m.mocks = invalid + end function + + ' /** + ' * @memberof module:BaseTestSuite + ' * @name cleanStubs + ' * @function + ' * @instance + ' * @description Cleans up all tracking data associated with stubs + ' */ + function cleanStubs() as void + if m.stubs = invalid then return + for each id in m.stubs + stub = m.stubs[id] + stub.target.__stubs = invalid + end for + m.stubs = invalid + end function - ' /** - ' * @memberof module:BaseTestSuite - ' * @name cleanStubs - ' * @function - ' * @instance - ' * @description Cleans up all tracking data associated with stubs - ' */ - function cleanStubs() as void - if m.stubs = invalid then return - for each id in m.stubs - stub = m.stubs[id] - stub.target.__stubs = invalid - end for - m.stubs = invalid - end function - - - function mockFail(lineNumber, methodName, message) as dynamic - if m.currentResult.isFail then return false - m.currentResult.fail("mock failure on '" + methodName + "' : " + message, lineNumber) - return false - end function - - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '++ Fake Stub callback functions - this is required to get scope - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - function stubCallback0(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__Stubs["0"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function stubCallback1(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__Stubs["1"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function stubCallback2(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__Stubs["2"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - - function stubCallback3(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__Stubs["3"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - - function stubCallback4(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__Stubs["4"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - - function stubCallback5(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__Stubs["5"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '++ Fake Mock callback functions - this is required to get scope - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - function mockCallback0(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["0"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback1(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["1"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback2(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["2"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback3(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["3"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback4(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["4"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback5(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["5"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback6(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["6"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback7(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["7"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback8(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["8"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback9(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["9"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback10(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["10"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback11(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["11"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback12(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["12"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback13(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["13"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback14(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["14"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback15(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["15"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback16(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["16"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback17(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["17"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback18(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["18"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback19(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["19"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback20(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["20"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback21(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["21"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback22(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["22"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback23(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["23"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - function mockCallback24(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic - fake = m.__mocks["24"] - return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '++ crude async support - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - ' /** - ' * @member waitForField - ' * @memberof module:TestUtils - ' * @instance - ' * @function - ' * @description observeField doesn't work in regular unit tests, so we have to wait for the result. We can use this to wait for a network task, foe example, and pass the result directly to a handler. Note - we wait for the value TO CHANGE - so make sure that will be the case, or you'll get stuck forever :) - ' * @param {any} target to observe - ' * @param {string} field to observe - ' * @param {int} delay for each wait - ' * @param {int} max attempts - ' */ - function waitForField(target, fieldName, delay = 500, maxAttempts = 10) - attempts = 0 - if target = invalid + function mockFail(lineNumber, methodName, message) as dynamic + if m.currentResult.isFail then return false + m.currentResult.fail("mock failure on '" + methodName + "' : " + message, lineNumber) return false - end if - - initialValue = target[fieldName] - while target[fieldName] = initialValue - port = CreateObject("roMessagePort") - wait(delay, port) - attempts++ - if attempts = maxAttempts + end function + + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '++ Fake Stub callback functions - this is required to get scope + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + function stubCallback0(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__Stubs["0"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function stubCallback1(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__Stubs["1"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function stubCallback2(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__Stubs["2"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + + function stubCallback3(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__Stubs["3"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + + function stubCallback4(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__Stubs["4"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + + function stubCallback5(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__Stubs["5"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '++ Fake Mock callback functions - this is required to get scope + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + function mockCallback0(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["0"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback1(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["1"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback2(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["2"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback3(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["3"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback4(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["4"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback5(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["5"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback6(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["6"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback7(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["7"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback8(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["8"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback9(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["9"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback10(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["10"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback11(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["11"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback12(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["12"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback13(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["13"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback14(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["14"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback15(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["15"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback16(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["16"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback17(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["17"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback18(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["18"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback19(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["19"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback20(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["20"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback21(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["21"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback22(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["22"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback23(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["23"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + function mockCallback24(arg1 = invalid, arg2 = invalid, arg3 = invalid, arg4 = invalid, arg5 = invalid, arg6 = invalid, arg7 = invalid, arg8 = invalid, arg9 = invalid)as dynamic + fake = m.__mocks["24"] + return fake.callback(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) + end function + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '++ crude async support + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + ' /** + ' * @member waitForField + ' * @memberof module:TestUtils + ' * @instance + ' * @function + ' * @description observeField doesn't work in regular unit tests, so we have to wait for the result. We can use this to wait for a network task, foe example, and pass the result directly to a handler. Note - we wait for the value TO CHANGE - so make sure that will be the case, or you'll get stuck forever :) + ' * @param {any} target to observe + ' * @param {string} field to observe + ' * @param {int} delay for each wait + ' * @param {int} max attempts + ' */ + function waitForField(target, fieldName, delay = 500, maxAttempts = 10) + attempts = 0 + if target = invalid return false end if - ? "waiting for signal field '" ; fieldName "' - " ; attempts - end while - return true - end function + initialValue = target[fieldName] + while target[fieldName] = initialValue + port = CreateObject("roMessagePort") + wait(delay, port) + attempts++ + if attempts = maxAttempts + return false + end if + ? "waiting for signal field '" ; fieldName "' - " ; attempts + end while + + return true + end function - function assertAsyncField(target, fieldName, delay = 500, maxAttempts = 10, lineNumber = -1) - if m.currentResult.isFail then return false - if target = invalid - m.fail("Target was invalid") - end if + function assertAsyncField(target, fieldName, delay = 500, maxAttempts = 10, lineNumber = -1) + if m.currentResult.isFail then return false + if target = invalid + m.fail("Target was invalid") + end if + + result = m.waitForField(target, fieldName, delay, maxAttempts) + if not result + return m.fail("Timeout waiting for targetField " + fieldName + " to be set on target", lineNumber) + end if - result = m.waitForField(target, fieldName, delay, maxAttempts) - if not result - return m.fail("Timeout waiting for targetField " + fieldName + " to be set on target", lineNumber) - end if + m.currentResult.fail("", -1) + return true + end function - m.currentResult.fail("", -1) - return true - end function + end class -end class \ No newline at end of file +end namespace \ No newline at end of file diff --git a/src/source/CommonUtils.bs b/src/source/CommonUtils.bs index e9abaffc..5f636e33 100755 --- a/src/source/CommonUtils.bs +++ b/src/source/CommonUtils.bs @@ -1,4 +1,4 @@ -namespace Common +namespace Rooibos.Common ' /** ' * @module CommonUtils ' */ @@ -15,7 +15,7 @@ namespace Common ' * @returns {Boolean} - true if value contains XMLElement interface, else return false ' */ function isXmlElement(value) as boolean - return Common.isValid(value) and GetInterface(value, "ifXMLElement") <> invalid + return Rooibos.Common.isValid(value) and GetInterface(value, "ifXMLElement") <> invalid end function ' /** @@ -27,12 +27,12 @@ namespace Common ' * @returns {Boolean} - true if value contains Function interface, else return false ' */ function isFunction(value) as boolean - return Common.isValid(value) and GetInterface(value, "ifFunction") <> invalid + return Rooibos.Common.isValid(value) and GetInterface(value, "ifFunction") <> invalid end function ' /** - ' * @name Common.getFunction + ' * @name Rooibos.Common.getFunction ' * @function ' * @description looks up the function by name, for the function map ' * @memberof module:CommonUtils @@ -41,8 +41,8 @@ namespace Common ' * @returns {Function} - function pointer or invalid ' */ function getFunction(filename, functionName) as object - if not Common.isNotEmptyString(functionName) then return invalid - if not Common.isNotEmptyString(filename) then return invalid + if not Rooibos.Common.isNotEmptyString(functionName) then return invalid + if not Rooibos.Common.isNotEmptyString(filename) then return invalid 'bs:disable-next-line mapFunction = RBSFM_getFunctionsForFile(filename) if mapFunction <> invalid @@ -59,7 +59,7 @@ namespace Common end function ' /** - ' * @name Common.getFunctionBruteforce + ' * @name Rooibos.Common.getFunctionBruteforce ' * @function ' * @description looks up the function by name, from any function map ' * in future @@ -69,7 +69,7 @@ namespace Common ' * @returns {Function} - function pointer or invalid ' */ function getFunctionBruteForce(functionName) as object - if not Common.isNotEmptyString(functionName) then return invalid + if not Rooibos.Common.isNotEmptyString(functionName) then return invalid 'bs:disable-next-line filenames = RBSFM_getFilenames() for i = 0 to filenames.count() - 1 @@ -99,7 +99,7 @@ namespace Common ' * @returns {Boolean} - true if value contains Boolean interface, else return false ' */ function isBoolean(value) as boolean - return Common.isValid(value) and GetInterface(value, "ifBoolean") <> invalid + return Rooibos.Common.isValid(value) and GetInterface(value, "ifBoolean") <> invalid end function ' /** @@ -111,7 +111,7 @@ namespace Common ' * @returns {Boolean} - true if value type equals Integer, else return false ' */ function isInteger(value) as boolean - return Common.isValid(value) and GetInterface(value, "ifInt") <> invalid and (Type(value) = "roInt" or Type(value) = "roInteger" or Type(value) = "Integer") + return Rooibos.Common.isValid(value) and GetInterface(value, "ifInt") <> invalid and (Type(value) = "roInt" or Type(value) = "roInteger" or Type(value) = "Integer") end function ' /** @@ -123,7 +123,7 @@ namespace Common ' * @returns {Boolean} - true if value contains Float interface, else return false ' */ function isFloat(value) as boolean - return Common.isValid(value) and GetInterface(value, "ifFloat") <> invalid + return Rooibos.Common.isValid(value) and GetInterface(value, "ifFloat") <> invalid end function ' /** @@ -135,7 +135,7 @@ namespace Common ' * @returns {Boolean} - true if value contains Double interface, else return false ' */ function isDouble(value) as boolean - return Common.isValid(value) and GetInterface(value, "ifDouble") <> invalid + return Rooibos.Common.isValid(value) and GetInterface(value, "ifDouble") <> invalid end function ' /** @@ -147,7 +147,7 @@ namespace Common ' * @returns {Boolean} - true if value contains LongInteger interface, else return false ' */ function isLongInteger(value) as boolean - return Common.isValid(value) and GetInterface(value, "ifLongInt") <> invalid + return Rooibos.Common.isValid(value) and GetInterface(value, "ifLongInt") <> invalid end function ' /** @@ -159,7 +159,7 @@ namespace Common ' * @returns {Boolean} - true if value is number, else return false ' */ function isNumber(value) as boolean - return Common.isLongInteger(value) or Common.isDouble(value) or Common.isInteger(value) or Common.isFloat(value) + return Rooibos.Common.isLongInteger(value) or Rooibos.Common.isDouble(value) or Rooibos.Common.isInteger(value) or Rooibos.Common.isFloat(value) end function ' /** @@ -171,7 +171,7 @@ namespace Common ' * @returns {Boolean} - true if value contains List interface, else return false ' */ function isList(value) as boolean - return Common.isValid(value) and GetInterface(value, "ifList") <> invalid + return Rooibos.Common.isValid(value) and GetInterface(value, "ifList") <> invalid end function ' /** @@ -183,7 +183,7 @@ namespace Common ' * @returns {Boolean} - true if value contains Array interface, else return false ' */ function isArray(value) as boolean - return Common.isValid(value) and GetInterface(value, "ifArray") <> invalid + return Rooibos.Common.isValid(value) and GetInterface(value, "ifArray") <> invalid end function ' /** @@ -195,7 +195,7 @@ namespace Common ' * @returns {Boolean} - true if value contains AssociativeArray interface, else return false ' */ function isAssociativeArray(value) as boolean - return Common.isValid(value) and GetInterface(value, "ifAssociativeArray") <> invalid + return Rooibos.Common.isValid(value) and GetInterface(value, "ifAssociativeArray") <> invalid end function ' /** @@ -207,7 +207,7 @@ namespace Common ' * @returns {Boolean} - true if value contains SGNodeChildren interface, else return false ' */ function isSGNode(value) as boolean - return Common.isValid(value) and GetInterface(value, "ifSGNodeChildren") <> invalid + return Rooibos.Common.isValid(value) and GetInterface(value, "ifSGNodeChildren") <> invalid end function ' /** @@ -219,7 +219,7 @@ namespace Common ' * @returns {Boolean} - true if value contains String interface, else return false ' */ function isString(value) as boolean - return Common.isValid(value) and GetInterface(value, "ifString") <> invalid + return Rooibos.Common.isValid(value) and GetInterface(value, "ifString") <> invalid end function ' /** @@ -231,7 +231,7 @@ namespace Common ' * @returns {Boolean} - true if value contains String interface and length more 0, else return false ' */ function isNotEmptyString(value) as boolean - return Common.isString(value) and len(value) > 0 + return Rooibos.Common.isString(value) and len(value) > 0 end function ' /** @@ -243,7 +243,7 @@ namespace Common ' * @returns {Boolean} - true if value contains DateTime interface, else return false ' */ function isDateTime(value) as boolean - return Common.isValid(value) and (GetInterface(value, "ifDateTime") <> invalid or Type(value) = "roDateTime") + return Rooibos.Common.isValid(value) and (GetInterface(value, "ifDateTime") <> invalid or Type(value) = "roDateTime") end function ' /** @@ -255,7 +255,7 @@ namespace Common ' * @returns {Boolean} - true if value initialized and not equal invalid, else return false ' */ function isValid(value) as boolean - return not Common.isUndefined(value) and value <> invalid + return not Rooibos.Common.isUndefined(value) and value <> invalid end function function isUndefined(value) as boolean @@ -287,13 +287,13 @@ namespace Common ' * @returns {String} - converted string ' */ function asString(input) as string - if Common.isValid(input) = false + if Rooibos.Common.isValid(input) = false return "Invalid" - else if Common.isString(input) + else if Rooibos.Common.isString(input) return input - else if Common.isInteger(input) or Common.isLongInteger(input) or Common.isBoolean(input) + else if Rooibos.Common.isInteger(input) or Rooibos.Common.isLongInteger(input) or Rooibos.Common.isBoolean(input) return input.ToStr() - else if Common.isFloat(input) or Common.isDouble(input) + else if Rooibos.Common.isFloat(input) or Rooibos.Common.isDouble(input) return Str(input).Trim() else if type(input) = "roSGNode" return "Node(" + input.subType() + ")" @@ -306,12 +306,12 @@ namespace Common end if for each key in input if key <> "__mocks" and key <> "__stubs" - text = text + key + ":" + Common.asString(input[key]) + text = text + key + ":" + Rooibos.Common.asString(input[key]) end if end for text = text + "}" return text - else if Common.isFunction(input) + else if Rooibos.Common.isFunction(input) return input.toStr() else return "" @@ -327,13 +327,13 @@ namespace Common ' * @returns {Integer} - converted Integer ' */ function asInteger(input) as integer - if Common.isValid(input) = false + if Rooibos.Common.isValid(input) = false return 0 - else if Common.isString(input) + else if Rooibos.Common.isString(input) return input.ToInt() - else if Common.isInteger(input) + else if Rooibos.Common.isInteger(input) return input - else if Common.isFloat(input) or Common.isDouble(input) or Common.isLongInteger(input) + else if Rooibos.Common.isFloat(input) or Rooibos.Common.isDouble(input) or Rooibos.Common.isLongInteger(input) return Int(input) else return 0 @@ -349,11 +349,11 @@ namespace Common ' * @returns {Integer} - converted LongInteger ' */ function asLongInteger(input) as longinteger - if Common.isValid(input) = false + if Rooibos.Common.isValid(input) = false return 0 - else if Common.isString(input) - return Common.asInteger(input) - else if Common.isLongInteger(input) or Common.isFloat(input) or Common.isDouble(input) or Common.isInteger(input) + else if Rooibos.Common.isString(input) + return Rooibos.Common.asInteger(input) + else if Rooibos.Common.isLongInteger(input) or Rooibos.Common.isFloat(input) or Rooibos.Common.isDouble(input) or Rooibos.Common.isInteger(input) return input else return 0 @@ -369,13 +369,13 @@ namespace Common ' * @returns {Float} - converted Float ' */ function asFloat(input) as float - if Common.isValid(input) = false + if Rooibos.Common.isValid(input) = false return 0.0 - else if Common.isString(input) + else if Rooibos.Common.isString(input) return input.ToFloat() - else if Common.isInteger(input) + else if Rooibos.Common.isInteger(input) return (input / 1) - else if Common.isFloat(input) or Common.isDouble(input) or Common.isLongInteger(input) + else if Rooibos.Common.isFloat(input) or Rooibos.Common.isDouble(input) or Rooibos.Common.isLongInteger(input) return input else return 0.0 @@ -391,11 +391,11 @@ namespace Common ' * @returns {Float} - converted Double ' */ function asDouble(input) as double - if Common.isValid(input) = false + if Rooibos.Common.isValid(input) = false return 0.0 - else if Common.isString(input) - return Common.asFloat(input) - else if Common.isInteger(input) or Common.isLongInteger(input) or Common.isFloat(input) or Common.isDouble(input) + else if Rooibos.Common.isString(input) + return Rooibos.Common.asFloat(input) + else if Rooibos.Common.isInteger(input) or Rooibos.Common.isLongInteger(input) or Rooibos.Common.isFloat(input) or Rooibos.Common.isDouble(input) return input else return 0.0 @@ -411,13 +411,13 @@ namespace Common ' * @returns {Boolean} - converted boolean ' */ function asBoolean(input) as boolean - if Common.isValid(input) = false + if Rooibos.Common.isValid(input) = false return false - else if Common.isString(input) + else if Rooibos.Common.isString(input) return LCase(input) = "true" - else if Common.isInteger(input) or Common.isFloat(input) + else if Rooibos.Common.isInteger(input) or Rooibos.Common.isFloat(input) return input <> 0 - else if Common.isBoolean(input) + else if Rooibos.Common.isBoolean(input) return input else return false @@ -433,8 +433,8 @@ namespace Common ' * @returns {Array} - converted array ' */ function asArray(value) as object - if Common.isValid(value) - if not Common.isArray(value) + if Rooibos.Common.isValid(value) + if not Rooibos.Common.isArray(value) return [value] else return value @@ -456,10 +456,10 @@ namespace Common ' * @returns {Boolean} - true if value is null or empty string, else return false ' */ function isNullOrEmpty(value) as boolean - if Common.isString(value) + if Rooibos.Common.isString(value) return Len(value) = 0 else - return not Common.isValid(value) + return not Rooibos.Common.isValid(value) end if end function @@ -479,15 +479,15 @@ namespace Common ' * @returns {Integer} - element index if array contains a value, else return -1 ' */ function findElementIndexInArray(array, value, compareAttribute = invalid, caseSensitive = false) as integer - if Common.isArray(array) - for i = 0 to Common.asArray(array).Count() - 1 + if Rooibos.Common.isArray(array) + for i = 0 to Rooibos.Common.asArray(array).Count() - 1 compareValue = array[i] - if compareAttribute <> invalid and Common.isAssociativeArray(compareValue) + if compareAttribute <> invalid and Rooibos.Common.isAssociativeArray(compareValue) compareValue = compareValue.lookupCI(compareAttribute) end if - if Common.eqValues(compareValue, value) + if Rooibos.Common.eqValues(compareValue, value) return i end if @@ -508,7 +508,7 @@ namespace Common ' * @returns {Boolean} - true if array contains a value, else return false ' */ function arrayContains(array, value, compareAttribute = invalid) as boolean - return (Common.findElementIndexInArray(array, value, compareAttribute) > -1) + return (Rooibos.Common.findElementIndexInArray(array, value, compareAttribute) > -1) end function @@ -546,7 +546,7 @@ namespace Common ' * @returns {Boolean} - true if node contains a value, else return false ' */ function nodeContains(node, value) as boolean - return (Common.findElementIndexInNode(node, value) > -1) + return (Rooibos.Common.findElementIndexInNode(node, value) > -1) end function @@ -570,13 +570,13 @@ namespace Common end if if val1Type = "roString" or val1Type = "String" - Value1 = Common.asString(Value1) + Value1 = Rooibos.Common.asString(Value1) else Value1 = box(Value1) end if if val2Type = "roString" or val2Type = "String" - Value2 = Common.asString(Value2) + Value2 = Rooibos.Common.asString(Value2) else Value2 = box(Value2) end if @@ -598,11 +598,11 @@ namespace Common valtype = val1Type if valtype = "roList" - return Common.eqArray(Value1, Value2) + return Rooibos.Common.eqArray(Value1, Value2) else if valtype = "roAssociativeArray" - return Common.eqAssocArray(Value1, Value2) + return Rooibos.Common.eqAssocArray(Value1, Value2) else if valtype = "roArray" - return Common.eqArray(Value1, Value2) + return Rooibos.Common.eqArray(Value1, Value2) else if valtype = "roSGNode" if val2Type <> "roSGNode" return false @@ -642,7 +642,7 @@ namespace Common else v1 = Value1[k] v2 = Value2[k] - if not Common.eqValues(v1, v2) + if not Rooibos.Common.eqValues(v1, v2) return false end if end if @@ -663,7 +663,7 @@ namespace Common ' * @returns {boolean} - True if arrays are equal or False in other case. ' */ function eqArray(Value1, Value2) as dynamic - if not (Common.isArray(Value1)) or not Common.isArray(Value) then return false + if not (Rooibos.Common.isArray(Value1)) or not Rooibos.Common.isArray(Value) then return false l1 = Value1.Count() l2 = Value2.Count() @@ -674,7 +674,7 @@ namespace Common for i = 0 to l1 - 1 v1 = Value1[i] v2 = Value2[i] - if not Common.eqValues(v1, v2) then + if not Rooibos.Common.eqValues(v1, v2) then return false end if end for diff --git a/src/source/Coverage.bs b/src/source/Coverage.bs index c9a5fc19..6203e1dd 100644 --- a/src/source/Coverage.bs +++ b/src/source/Coverage.bs @@ -1,4 +1,4 @@ -namespace Coverage +namespace Rooibos.Coverage function createLCovOutput() ? "Generating lcov.info file..." diff --git a/src/source/Matchers.bs b/src/source/Matchers.bs index 5c006729..e2c86ba4 100644 --- a/src/source/Matchers.bs +++ b/src/source/Matchers.bs @@ -1,27 +1,27 @@ -namespace Matcher +namespace Rooibos.Matcher function anyString(value) - return Common.isString(value) + return Rooibos.Common.isString(value) end function function anyBool(value) - return Common.isBoolean(value) + return Rooibos.Common.isBoolean(value) end function function anyNumber(value) - return Common.isNumber(value) + return Rooibos.Common.isNumber(value) end function function anyAA(value) - return Common.isAssociativeArray(value) + return Rooibos.Common.isAssociativeArray(value) end function function anyArray(value) - return Common.isArray(value) + return Rooibos.Common.isArray(value) end function function anyNode(value) - return Common.isSGNode(value) + return Rooibos.Common.isSGNode(value) end function diff --git a/src/source/Rooibos.bs b/src/source/Rooibos.bs index dabd8b48..e8a2254f 100644 --- a/src/source/Rooibos.bs +++ b/src/source/Rooibos.bs @@ -1,129 +1,131 @@ -' /** -' * @module rooibos -' */ -' /** -' * @memberof module:rooibos -' * @name Rooibos_init -' * @function -' * @description Entry point for rooibos unit testing framework. Will identify, run, and report all tests in the app, before terminating the application. -' * @param {Dynamic} preTestSetup - called to do any initialization once the screen is created -' * Use this to configure anything such as globals, etc that you need -' * @param {Dynamic} testUtilsDecorator - will be invoked, with the test case as a param - the function -' * can then compose/decorate any additional functionality, as required -' * Use this to add things like, rodash, common test utils, etc -' * @param testsSceneName as string - name of scene to create. All unit tests run in the scene thread -' * and therefore require a screen and scene are created. -' * @param nodeContext as object - this is the global scope of your tests - so where anonymous methods will run from. This should be m -' */ -function init(testSceneName = invalid, nodeContext = invalid) as void - args = {} - if createObject("roAPPInfo").IsDev() <> true then - ? " not running in dev mode! - rooibos tests only support sideloaded builds - aborting" - return - end if - - screen = CreateObject("roSGScreen") - m.port = CreateObject("roMessagePort") - screen.setMessagePort(m.port) - if testSceneName = invalid - testSceneName = "TestsScene" - end if - - ? "Starting test using test scene with name TestsScene" ; testSceneName - scene = screen.CreateScene(testSceneName) - scene.id = "ROOT" - screen.show() - - m.global = screen.getGlobalNode() - m.global.addFields({ "testsScene": scene }) - - args.testScene = scene - args.global = m.global - rooibosVersion = "#ROOIBOS_VERSION#" - requiredPluginVersion = "1.0.0" - - 'bs:disable-next-line - if versionCompare(rooibos_getPluginVersion(), requiredPluginVersion) >= 0 - versionError = "" - else - 'bs:disable-next-line - versionError = "Your rooibos-preprocessor (i.e. rooibos-cli) version '" + rooibos_getPluginVersion() + "' is not compatible with rooibos version " + rooibosVersion + ". Please upgrade your rooibos-cli to version " + requiredPluginVersion - end if +namespace Rooibos + ' /** + ' * @module rooibos + ' */ + ' /** + ' * @memberof module:rooibos + ' * @name Rooibos_init + ' * @function + ' * @description Entry point for rooibos unit testing framework. Will identify, run, and report all tests in the app, before terminating the application. + ' * @param {Dynamic} preTestSetup - called to do any initialization once the screen is created + ' * Use this to configure anything such as globals, etc that you need + ' * @param {Dynamic} testUtilsDecorator - will be invoked, with the test case as a param - the function + ' * can then compose/decorate any additional functionality, as required + ' * Use this to add things like, rodash, common test utils, etc + ' * @param testsSceneName as string - name of scene to create. All unit tests run in the scene thread + ' * and therefore require a screen and scene are created. + ' * @param nodeContext as object - this is the global scope of your tests - so where anonymous methods will run from. This should be m + ' */ + function init(testSceneName = invalid, nodeContext = invalid) as void + args = {} + if createObject("roAPPInfo").IsDev() <> true then + ? " not running in dev mode! - rooibos tests only support sideloaded builds - aborting" + return + end if - if versionError = "" - ? "######################################################" - ? "" - ? "# rooibos framework version: " ; rooibosVersion - 'bs:disable-next-line - ? "# tests ran with rooibos-roku-vsc-extension-plugin version: " ; rooibos_getPluginVersion() - ? "######################################################" - ? "" + screen = CreateObject("roSGScreen") + m.port = CreateObject("roMessagePort") + screen.setMessagePort(m.port) + if testSceneName = invalid + testSceneName = "TestsScene" + end if + + ? "Starting test using test scene with name TestsScene" ; testSceneName + scene = screen.CreateScene(testSceneName) + scene.id = "ROOT" + screen.show() + + m.global = screen.getGlobalNode() + m.global.addFields({ "testsScene": scene }) - if scene.hasField("isReadyToStartTests") and scene.isReadyToStartTests = false - ? "The scene is not ready yet - waiting for it to set isReadyToStartTests to true" - scene.observeField("isReadyToStartTests", m.port) + args.testScene = scene + args.global = m.global + rooibosVersion = "#ROOIBOS_VERSION#" + requiredPluginVersion = "1.0.0" + 'bs:disable-next-line + if versionCompare(rooibos_getPluginVersion(), requiredPluginVersion) >= 0 + versionError = "" else - ? "scene is ready; running tests now" - runner = new TestRunner(args, m) - runner.Run() - end if + 'bs:disable-next-line + versionError = "Your rooibos-preprocessor (i.e. rooibos-cli) version '" + rooibos_getPluginVersion() + "' is not compatible with rooibos version " + rooibosVersion + ". Please upgrade your rooibos-cli to version " + requiredPluginVersion + end if + + if versionError = "" + ? "######################################################" + ? "" + ? "# rooibos framework version: " ; rooibosVersion + 'bs:disable-next-line + ? "# tests ran with rooibos-roku-vsc-extension-plugin version: " ; rooibos_getPluginVersion() + ? "######################################################" + ? "" + + if scene.hasField("isReadyToStartTests") and scene.isReadyToStartTests = false + ? "The scene is not ready yet - waiting for it to set isReadyToStartTests to true" + scene.observeField("isReadyToStartTests", m.port) + + else + ? "scene is ready; running tests now" + runner = new TestRunner(args, m) + runner.Run() + end if - while(true) - msg = wait(0, m.port) - msgType = type(msg) - if msgType = "roSGScreenEvent" - if msg.isScreenClosed() - return + while(true) + msg = wait(0, m.port) + msgType = type(msg) + if msgType = "roSGScreenEvent" + if msg.isScreenClosed() + return + end if + else if msgType = "roSGNodeEvent" + + if msg.getField() = "isReadyToStartTests" and msg.getData() = true + ? "scene is ready; running tests now" + runner = new TestRunner(args, m) + runner.Run() + end if end if - else if msgType = "roSGNodeEvent" + end while + else + ? "" + ? "#########################################################" + ? "ERROR - VERSION MISMATCH" + ? versionError + ? "#########################################################" + end if + end function - if msg.getField() = "isReadyToStartTests" and msg.getData() = true - ? "scene is ready; running tests now" - runner = new TestRunner(args, m) - runner.Run() - end if - end if + function versionCompare(v1, v2) + v1parts = v1.split(".") + v2parts = v2.split(".") + + while v1parts.count() < v2parts.count() + v1parts.push("0") + end while + + while v2parts.count() < v1parts.count() + v2parts.push("0") end while - else - ? "" - ? "#########################################################" - ? "ERROR - VERSION MISMATCH" - ? versionError - ? "#########################################################" - end if -end function - -function versionCompare(v1, v2) - v1parts = v1.split(".") - v2parts = v2.split(".") - - while v1parts.count() < v2parts.count() - v1parts.push("0") - end while - - while v2parts.count() < v1parts.count() - v2parts.push("0") - end while - - for i = 0 to v1parts.count() - 1 - if v2parts.count() = i - return 1 - end if - if v1parts[i] <> v2parts[i] - if v1parts[i] > v2parts[i] + for i = 0 to v1parts.count() - 1 + if v2parts.count() = i return 1 - else - return -1 end if - end if - end for - if v1parts.count() <> v2parts.count() - return -1 - end if + if v1parts[i] <> v2parts[i] + if v1parts[i] > v2parts[i] + return 1 + else + return -1 + end if + end if + end for + + if v1parts.count() <> v2parts.count() + return -1 + end if - return 0 + return 0 -end function \ No newline at end of file + end function +end namespace \ No newline at end of file diff --git a/src/source/RooibosScene.xml b/src/source/RooibosScene.xml new file mode 100644 index 00000000..9af58cb8 --- /dev/null +++ b/src/source/RooibosScene.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/source/RuntimeConfig.bs b/src/source/RuntimeConfig.bs index 0a035a74..6979fd58 100644 --- a/src/source/RuntimeConfig.bs +++ b/src/source/RuntimeConfig.bs @@ -1,37 +1,21 @@ -class RuntimeConfig +namespace Rooibos + class RuntimeConfig - public hasSoloSuites = false - public hasSoloGroups = false - public hasSoloTests = false + function getVersionText() + 'generated + end function - function new() - m.suites = m.createSuites() - end function + function getRuntimeConfig() + 'generated + end function - function createSuites() - 'bs:disable-next-line - suites = rooibos_getTestSuitesForProject() - includedSuites = [] - for i = 0 to suites.count() - 1 - suite = suites[i] - if suite.valid - if suite.isSolo - m.hasSoloSuites = true - end if - if suite.hasSoloTests = true - m.hasSoloTests = true - end if - if suite.hasSoloGroups = true - m.hasSoloGroups = true - end if - ' ? "valid - suite" - includedSuites.push(suite) - else - ? "ERROR! suite was not valid - ignoring" - end if + function getTestSuiteClassWithName(name) + 'generated + end function - end for - return includedSuites - end function + function getGlobalScopeTestSuitesNames() + 'generated + end function -end class \ No newline at end of file + end class +end namespace \ No newline at end of file diff --git a/src/source/Stats.bs b/src/source/Stats.bs index f2c585df..e2f4adf1 100644 --- a/src/source/Stats.bs +++ b/src/source/Stats.bs @@ -1,44 +1,46 @@ -class Stats - public time = 0 - public ranCount = 0 - public passedCount = 0 - public failedCount = 0 - public crashedCount = 0 - public ignoredCount = 0 - public ignoredTestNames = [] - public hasFailures = false - public testResult = invalid +namespace Rooibos + class Stats + public time = 0 + public ranCount = 0 + public passedCount = 0 + public failedCount = 0 + public crashedCount = 0 + public ignoredCount = 0 + public ignoredTestNames = [] + public hasFailures = false + public testResult = invalid - function new() - end function + function new() + end function - function merge(other) as void - m.time += other.time - m.ranCount += other.ranCount - m.passedCount += other.passedCount - m.failedCount += other.failedCount - m.crashedCount += other.crashedCount - m.ignoredCount += other.ignoredCount - m.ignoredTestNames.append(other.IgnoredTestNames) - m.onUpdate() - end function + function merge(other) as void + m.time += other.time + m.ranCount += other.ranCount + m.passedCount += other.passedCount + m.failedCount += other.failedCount + m.crashedCount += other.crashedCount + m.ignoredCount += other.ignoredCount + m.ignoredTestNames.append(other.IgnoredTestNames) + m.onUpdate() + end function - function appendTestResult(testResult) - m.time += testResult.time - m.ranCount++ - if testResult.isCrash - m.crashedCount++ - else if testResult.isFail - m.failedCount++ - else - m.passedCount++ - end if + function appendTestResult(testResult) + m.time += testResult.time + m.ranCount++ + if testResult.isCrash + m.crashedCount++ + else if testResult.isFail + m.failedCount++ + else + m.passedCount++ + end if - m.onUpdate() - end function + m.onUpdate() + end function - function onUpdate() - m.hasFailures = m.failedCount > 0 or m.crashedCount > 0 - end function + function onUpdate() + m.hasFailures = m.failedCount > 0 or m.crashedCount > 0 + end function -end class \ No newline at end of file + end class +end namespace \ No newline at end of file diff --git a/src/source/Test.bs b/src/source/Test.bs index 46e198c6..96e5b494 100644 --- a/src/source/Test.bs +++ b/src/source/Test.bs @@ -1,113 +1,111 @@ -class Test +namespace Rooibos + class Test - public name - public isSolo - public funcName - public isIgnored - public lineNumber - public paramLineNumber - public testSuite = invalid - public testGroup = invalid + public name + public isSolo + public funcName + public isIgnored + public lineNumber + public paramLineNumber + public testSuite = invalid + public testGroup = invalid - public rawParams - public paramTestIndex - public isParamTest = false - public isParamsValid = false + public rawParams + public paramTestIndex + public isParamTest = false + public isParamsValid = false - public result = invalid + public result = invalid - function new(testGroup, data) - m.testGroup = testGroup - m.testSuite = testGroup.testSuite - m.isSolo = data.isSolo - m.funcName = data.funcName - m.isIgnored = data.isIgnored - m.name = data.name - m.lineNumber = data.lineNumber - m.paramLineNumber = data.paramLineNumber - m.rawParams = data.params - m.paramTestIndex = data.paramTestIndex - m.isParamTest = data.isParamTest - m.isParamsValid = data.isParamsValid - m.expectedNumberOfParams = data.expectedNumberOfParams - - if params <> invalid - m.name = m.name + stri(m.paramTestIndex) - end if - - m.result = new TestResult(m) - return this - end function - - function run() - timer = createObject("roTimespan") - timer.mark() - - if m.isParamsValid - if m.isParamTest - m.runParmsTest() - else - m.testSuite[m.funcName]() - end if - else - m.testSuite.fail("Could not parse args for test ") - end if - - m.result.time = timer.totalMilliseconds() + function new(testGroup, data) + m.testGroup = testGroup + m.testSuite = testGroup.testSuite + m.isSolo = data.isSolo + m.funcName = data.funcName + m.isIgnored = data.isIgnored + m.name = data.name + m.lineNumber = data.lineNumber + m.paramLineNumber = data.paramLineNumber + m.rawParams = data.params + m.paramTestIndex = data.paramTestIndex + m.isParamTest = data.isParamTest + m.isParamsValid = data.isParamsValid + m.expectedNumberOfParams = data.expectedNumberOfParams - end function + if params <> invalid + m.name = m.name + stri(m.paramTestIndex) + end if - function runParamsTest() - testParams = m.getTestParams() + m.result = new TestResult(m) + return this + end function - if m.expectedNumberOfParams = 1 - m.testSuite[m.funcName](testParams[0]) - else if m.expectedNumberOfParams = 2 - m.testSuite[m.funcName](testParams[0], testParams[1]) - else if m.expectedNumberOfParams = 3 - m.testSuite[m.funcName](testParams[0], testParams[1], testParams[2]) - else if m.expectedNumberOfParams = 4 - m.testSuite[m.funcName](testParams[0], testParams[1], testParams[2], testParams[3]) - else if m.expectedNumberOfParams = 5 - m.testSuite[m.funcName](testParams[0], testParams[1], testParams[2], testParams[3], testParams[4]) - else if m.expectedNumberOfParams = 6 - m.testSuite[m.funcName](testParams[0], testParams[1], testParams[2], testParams[3], testParams[4], testParams[5]) - else if m.expectedNumberOfParams = 7 - m.testSuite[m.funcName](testParams[0], testParams[1], testParams[2], testParams[3], testParams[4], testParams[5], testParams[6]) - else if m.expectedNumberOfParams = 8 - m.testSuite[m.funcName](testParams[0], testParams[1], testParams[2], testParams[3], testParams[4], testParams[5], testParams[6], testParams[7]) - else if m.expectedNumberOfParams = 9 - m.testSuite[m.funcName](testParams[0], testParams[1], testParams[2], testParams[3], testParams[4], testParams[5], testParams[6], testParams[7], testParams[8]) - else if m.expectedNumberOfParams = 10 - m.testSuite[m.funcName](testParams[0], testParams[1], testParams[2], testParams[3], testParams[4], testParams[5], testParams[6], testParams[7], testParams[8], testParams[9]) - else if m.expectedNumberOfParams = 11 - m.testSuite[m.funcName](testParams[0], testParams[1], testParams[2], testParams[3], testParams[4], testParams[5], testParams[6], testParams[7], testParams[8], testParams[9], testParams[10]) - else if m.expectedNumberOfParams = 12 - m.testSuite[m.funcName](testParams[0], testParams[1], testParams[2], testParams[3], testParams[4], testParams[5], testParams[6], testParams[7], testParams[8], testParams[9], testParams[10], testParams[11]) - else if m.expectedNumberOfParams > 12 - m.testSuite.fail("Test case had more than 12 params. Max of 12 params is supported") - end if - end function + function run() + timer = createObject("roTimespan") + timer.mark() - function getTestsParams() - params = [] - for paramIndex = 0 to m.rawParams.count() - paramValue = m.rawParams[paramIndex] - if type(paramValue) = "roString" and len(paramValue) >= 8 and left(paramValue, 8) = "#RBSNode" - nodeType = "ContentNode" - paramDirectiveArgs = paramValue.split("|") - if paramDirectiveArgs.count() > 1 - nodeType = paramDirectiveArgs[1] + if m.isParamsValid + if m.isParamTest + m.runParmsTest() + else + m.testSuite[m.funcName]() end if - paramValue = createObject("roSGNode", nodeType) + else + m.testSuite.fail("Could not parse args for test ") end if - params.push(paramValue) - end for - return params - end function - -end class + m.result.time = timer.totalMilliseconds() + end function + function runParamsTest() + testParams = m.getTestParams() + + if m.expectedNumberOfParams = 1 + m.testSuite[m.funcName](testParams[0]) + else if m.expectedNumberOfParams = 2 + m.testSuite[m.funcName](testParams[0], testParams[1]) + else if m.expectedNumberOfParams = 3 + m.testSuite[m.funcName](testParams[0], testParams[1], testParams[2]) + else if m.expectedNumberOfParams = 4 + m.testSuite[m.funcName](testParams[0], testParams[1], testParams[2], testParams[3]) + else if m.expectedNumberOfParams = 5 + m.testSuite[m.funcName](testParams[0], testParams[1], testParams[2], testParams[3], testParams[4]) + else if m.expectedNumberOfParams = 6 + m.testSuite[m.funcName](testParams[0], testParams[1], testParams[2], testParams[3], testParams[4], testParams[5]) + else if m.expectedNumberOfParams = 7 + m.testSuite[m.funcName](testParams[0], testParams[1], testParams[2], testParams[3], testParams[4], testParams[5], testParams[6]) + else if m.expectedNumberOfParams = 8 + m.testSuite[m.funcName](testParams[0], testParams[1], testParams[2], testParams[3], testParams[4], testParams[5], testParams[6], testParams[7]) + else if m.expectedNumberOfParams = 9 + m.testSuite[m.funcName](testParams[0], testParams[1], testParams[2], testParams[3], testParams[4], testParams[5], testParams[6], testParams[7], testParams[8]) + else if m.expectedNumberOfParams = 10 + m.testSuite[m.funcName](testParams[0], testParams[1], testParams[2], testParams[3], testParams[4], testParams[5], testParams[6], testParams[7], testParams[8], testParams[9]) + else if m.expectedNumberOfParams = 11 + m.testSuite[m.funcName](testParams[0], testParams[1], testParams[2], testParams[3], testParams[4], testParams[5], testParams[6], testParams[7], testParams[8], testParams[9], testParams[10]) + else if m.expectedNumberOfParams = 12 + m.testSuite[m.funcName](testParams[0], testParams[1], testParams[2], testParams[3], testParams[4], testParams[5], testParams[6], testParams[7], testParams[8], testParams[9], testParams[10], testParams[11]) + else if m.expectedNumberOfParams > 12 + m.testSuite.fail("Test case had more than 12 params. Max of 12 params is supported") + end if + end function + + function getTestsParams() + params = [] + for paramIndex = 0 to m.rawParams.count() + paramValue = m.rawParams[paramIndex] + if type(paramValue) = "roString" and len(paramValue) >= 8 and left(paramValue, 8) = "#RBSNode" + nodeType = "ContentNode" + paramDirectiveArgs = paramValue.split("|") + if paramDirectiveArgs.count() > 1 + nodeType = paramDirectiveArgs[1] + end if + paramValue = createObject("roSGNode", nodeType) + end if + params.push(paramValue) + end for + return params + end function + end class +end namespace \ No newline at end of file diff --git a/src/source/TestGroup.bs b/src/source/TestGroup.bs index 2dccb77e..cdc40a78 100644 --- a/src/source/TestGroup.bs +++ b/src/source/TestGroup.bs @@ -1,60 +1,53 @@ -' /** -' * @module TestSuite -' * @description All brs files that include `'@TestSuite` annotations automatically extend the TestSuite. -' * The base test suite contains all of the assertions, and utility methods required to writey our tests, as well as being responsible for tracking the state of the tests and groups. -' */ -class TestGroup - 'test state - name = "Unnamed Suite" - - testSuite = invalid - ignoredTestCases = [] - soloTestCases = [] - setupFunctionName = invalid - tearDownFunctionName = invalid - beforeEachFunctionName = invalid - afterEachFunctionName = invalid - isSolo = false - isLegacy = false - isIgnored = false - hasSoloTests = false - stats = invalid - tests = [] - - function new(data, testSuite) - m.testSuite = testSuite - m.name = data.name - m.valid = data.valid - m.hasFailures = data.hasFailures - m.hasSoloTests = data.hasSoloTests - m.hasIgnoredTests = data.hasIgnoredTests - m.hasSoloGroups = data.hasSoloGroups - m.isSolo = data.isSolo - m.isIgnored = data.isIgnored - m.testsData = data.tests - m.isNodeTest = false - m.nodeName = invalid - m.setupFunctionName = data.setupFunctionName - m.tearDownFunctionName = data.tearDownFunctionName - m.beforeEachFunctionName = data.beforeEachFunctionName - m.afterEachFunctionName = data.afterEachFunctionName - - m.context = nodeContext - m.global = nodeContext.gobal - m.top = nodeContext.top - m.stats = new Stats() - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '++ running - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - function run() - m.runSuiteFunction(m.setupFunctionName, "setup") - - for each testData in m.getTestCaseData - - if not m.testSuite.runHasSoloTests or test.isSolo +namespace Rooibos + ' /** + ' * @module TestSuite + ' * @description All brs files that include `'@TestSuite` annotations automatically extend the TestSuite. + ' * The base test suite contains all of the assertions, and utility methods required to writey our tests, as well as being responsible for tracking the state of the tests and groups. + ' */ + class TestGroup + 'test state + name = "Unnamed Suite" + + testSuite = invalid + setupFunctionName = invalid + tearDownFunctionName = invalid + beforeEachFunctionName = invalid + afterEachFunctionName = invalid + isSolo = false + isLegacy = false + isIgnored = false + stats = invalid + tests = [] + + function new(testSuite, data) + m.testSuite = testSuite + m.name = data.name + m.valid = data.valid + m.hasFailures = testSuite.hasFailures + m.isSolo = data.isSolo + m.isIgnored = data.isIgnored + m.testsData = data.tests + m.isNodeTest = false + m.nodeName = invalid + m.setupFunctionName = data.setupFunctionName + m.tearDownFunctionName = data.tearDownFunctionName + m.beforeEachFunctionName = data.beforeEachFunctionName + m.afterEachFunctionName = data.afterEachFunctionName + + m.context = nodeContext + m.global = nodeContext.gobal + m.top = nodeContext.top + m.stats = new Stats() + end function + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '++ running + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + function run() + m.runSuiteFunction(m.setupFunctionName, "setup") + + for each testsData in m.getTestCaseData test = new Test(m, testData) m.tests.push(test) m.runSuiteFunction(m.beforeEachFunctionName, "beforeEach") @@ -68,28 +61,24 @@ class TestGroup ? "Terminating group due to failed test" exit for end if - end if - end for + end for - m.runSuiteFunction(m.tearDownFunctionName, "tearDown") - end function + m.runSuiteFunction(m.tearDownFunctionName, "tearDown") + end function - private function getTestCaseData() - if m.hasSoloTests - return m.soloTestCases - else + private function getTestCaseData() return m.testCases - end if - end function + end function - private function runSuiteFunction(methodName, defaultFunctionName) - if methodName <> invalid and methodName <> "" - m.testSuite[methodName]() - else - m.testSuite[defaultMethodName]() - end if + private function runSuiteFunction(methodName, defaultFunctionName) + if methodName <> invalid and methodName <> "" + m.testSuite[methodName]() + else + m.testSuite[defaultMethodName]() + end if - end function + end function -end class \ No newline at end of file + end class +end namespace \ No newline at end of file diff --git a/src/source/TestLogger.bs b/src/source/TestLogger.bs index c5403a23..93ba1cf0 100644 --- a/src/source/TestLogger.bs +++ b/src/source/TestLogger.bs @@ -1,133 +1,135 @@ -class TestLogger - - function new(testRunner) - m.testRunner = testRunner - m.config = testRunner.config - m.allStats = testRunner.stats - end function - - function printStats() - m.startReport() - - for each testSuite in m.testRunner.testSuites - if not m.allTests.hasFailures or ((not m.config.showOnlyFailures) or testSuite.failedCount > 0 or testSuite.crashedCount > 0) - m.startSuiteReport(testSuite) - - for each testGroup in testSuite.groups - m.printGroup(testGroup) - end for - end if - end for - - ? "" - m.endReport() - - 'bs:disable-next-line - ignoredInfo = rooibos_getIgnoredTestInfo() - ? "Total = "; Common.AsString(m.allStats.total); " ; Passed = "; m.allStats.passedCount; " ; Failed = "; m.allStats.failedCount; " ; Ignored = "; ignoredInfo.count - ? " Time spent: "; m.allStats.time; "ms" - ? "" - ? "" - - if ignoredInfo.count > 0 - ? "IGNORED TESTS:" - for each ignoredItemName in ignoredInfo.items - print ignoredItemName +namespace Rooibos + class TestLogger + + function new(testRunner) + m.testRunner = testRunner + m.config = testRunner.config + m.allStats = testRunner.stats + end function + + function printStats() + m.startReport() + + for each testSuite in m.testRunner.testSuites + if not m.allTests.hasFailures or ((not m.config.showOnlyFailures) or testSuite.failedCount > 0 or testSuite.crashedCount > 0) + m.startSuiteReport(testSuite) + + for each testGroup in testSuite.groups + m.printGroup(testGroup) + end for + end if end for + + ? "" + m.endReport() + + 'bs:disable-next-line + ignoredInfo = rooibos_getIgnoredTestInfo() + ? "Total = "; Rooibos.Common.AsString(m.allStats.total); " ; Passed = "; m.allStats.passedCount; " ; Failed = "; m.allStats.failedCount; " ; Ignored = "; ignoredInfo.count + ? " Time spent: "; m.allStats.time; "ms" ? "" ? "" - end if - if stats.hasFailures - overrallResult = "Success" - else - overrallResult = "Fail" - end if - ? "RESULT: "; overrallResult + if ignoredInfo.count > 0 + ? "IGNORED TESTS:" + for each ignoredItemName in ignoredInfo.items + print ignoredItemName + end for + ? "" + ? "" + end if - end function + if stats.hasFailures + overrallResult = "Success" + else + overrallResult = "Fail" + end if + ? "RESULT: "; overrallResult - function printGroup(testGroup) - m.printGroupStart(testGrup) + end function - for each test in testGroup.tests - if not m.allStats.hasFailures or ((not m.config.showOnlyFailures) or test.result.isFail) - m.printTest(test) - end if - end for - - ? " |" - end function - - function printTest(test) - if test.result.isFail - testChar = "-" - locationLine = StrI(test.result.lineNumber).trim() - else - testChar = "|" - locationLine = StrI(test.lineNumber).trim() - end if - - locationText = "pkg:/" + test.testSuite.filePath.trim() + "(" + locationLine + ")" - - if m.config.printTestTimes = true - timeText = " (" + stri(test.result.time).trim() + "ms)" - else - timeText = "" - end if - - insetText = "" - if test.isParamTest <> true - messageLine = Common.fillText(" " + testChar + " |--" + test.name + " : ", ".", 80) - ? messageLine ; test.result.getStatusText() ; timeText - else if test.paramTestIndex = 0 - name = test.name - if len(name) > 1 and right(name, 1) = "0" - name = left(name, len(name) - 1) + function printGroup(testGroup) + m.printGroupStart(testGrup) + + for each test in testGroup.tests + if not m.allStats.hasFailures or ((not m.config.showOnlyFailures) or test.result.isFail) + m.printTest(test) + end if + end for + + ? " |" + end function + + function printTest(test) + if test.result.isFail + testChar = "-" + locationLine = StrI(test.result.lineNumber).trim() + else + testChar = "|" + locationLine = StrI(test.lineNumber).trim() end if - ? " " + testChar + " |--" + name + " : " - end if - - if test.isParamTest = true - insetText = " " - - if type(test.rawParams) = "roAssociativeArray" - rawParams = {} - for each key in test.rawParams - if type(test.rawParams[key]) <> "Function" and type(test.rawParams[key]) <> "roFunction" - rawParams[key] = test.rawParams[key] - end if - end for + + locationText = "pkg:/" + test.testSuite.filePath.trim() + "(" + locationLine + ")" + + if m.config.printTestTimes = true + timeText = " (" + stri(test.result.time).trim() + "ms)" else - rawParams = test.rawParams + timeText = "" + end if + + insetText = "" + if test.isParamTest <> true + messageLine = Rooibos.Common.fillText(" " + testChar + " |--" + test.name + " : ", ".", 80) + ? messageLine ; test.result.getStatusText() ; timeText + else if test.paramTestIndex = 0 + name = test.name + if len(name) > 1 and right(name, 1) = "0" + name = left(name, len(name) - 1) + end if + ? " " + testChar + " |--" + name + " : " end if - messageLine = Common.fillText(" " + testChar + insetText + " |--" + formatJson(rawParams) + " : ", ".", 80) - ? messageLine ; test.result.getStatusText() ; timeText - end if - if not test.isFail - ? " | "; insettext ;" |--Location: "; locationText if test.isParamTest = true - ? " | "; insettext ;" |--Param Line: "; StrI(test.paramlineNumber).trim() + insetText = " " + + if type(test.rawParams) = "roAssociativeArray" + rawParams = {} + for each key in test.rawParams + if type(test.rawParams[key]) <> "Function" and type(test.rawParams[key]) <> "roFunction" + rawParams[key] = test.rawParams[key] + end if + end for + else + rawParams = test.rawParams + end if + messageLine = Rooibos.Common.fillText(" " + testChar + insetText + " |--" + formatJson(rawParams) + " : ", ".", 80) + ? messageLine ; test.result.getStatusText() ; timeText + end if + + if not test.isFail + ? " | "; insettext ;" |--Location: "; locationText + if test.isParamTest = true + ? " | "; insettext ;" |--Param Line: "; StrI(test.paramlineNumber).trim() + end if + ? " | "; insettext ;" |--Error Message: "; test.result.message end if - ? " | "; insettext ;" |--Error Message: "; test.result.message - end if - end function - - function startReport() - ? "" - ? "[START TEST REPORT]" - ? "" - end function - - function endReport() - ? "" - ? "[END TEST REPORT]" - ? "" - end function - - function printGroupStart(testGroup) - ? " |-" ; testGroup.name - end function - -end class \ No newline at end of file + end function + + function startReport() + ? "" + ? "[START TEST REPORT]" + ? "" + end function + + function endReport() + ? "" + ? "[END TEST REPORT]" + ? "" + end function + + function printGroupStart(testGroup) + ? " |-" ; testGroup.name + end function + + end class +end namespace \ No newline at end of file diff --git a/src/source/TestResult.bs b/src/source/TestResult.bs index 434793d7..1921dd63 100644 --- a/src/source/TestResult.bs +++ b/src/source/TestResult.bs @@ -1,69 +1,71 @@ -class TestResult +namespace Rooibos + class TestResult - public isFail = false - public isCrash = false - public message = invalid - public lineNumber = -1 - public test = invalid - public time = 0 + public isFail = false + public isCrash = false + public message = invalid + public lineNumber = -1 + public test = invalid + public time = 0 - function new(test) - m.test = test - end function + function new(test) + m.test = test + end function - function reset() as void - m.isFail = false - m.isCrash = false - m.time = 0 - m.message = "" - m.lineNumber = -1 - end function + function reset() as void + m.isFail = false + m.isCrash = false + m.time = 0 + m.message = "" + m.lineNumber = -1 + end function - function fail(message as string, lineNumber = -1) - if message <> "" and not m.isFail - if not m.isFail - m.lineNumber = lineNumber - m.isFail = true + function fail(message as string, lineNumber = -1) + if message <> "" and not m.isFail + if not m.isFail + m.lineNumber = lineNumber + m.isFail = true + end if end if - end if - end function + end function - function crash(message as string, lineNumber = -1) - if message <> "" and not m.isCrash - if not m.isCrash - m.lineNumber = lineNumber - m.isFail = true - m.isCrash = true + function crash(message as string, lineNumber = -1) + if message <> "" and not m.isCrash + if not m.isCrash + m.lineNumber = lineNumber + m.isFail = true + m.isCrash = true + end if end if - end if - end function + end function - function getMessage() as string - if m.isFail - if m.message <> invalid - return m.message + function getMessage() as string + if m.isFail + if m.message <> invalid + return m.message + else + return "unknown test failure" + end if + else if m.isCrash + if m.message <> invalid + return m.message + else + return "unknown test crash" + end if else - return "unknown test failure" + return "" end if - else if m.isCrash - if m.message <> invalid - return m.message + end function + + function getStatusText() + if m.isFail + return "FAIL" + else if m.isCrash + return "CRASH" else - return "unknown test crash" + return "PASS" end if - else - return "" - end if - end function - - function getStatusText() - if m.isFail - return "FAIL" - else if m.isCrash - return "CRASH" - else - return "PASS" - end if - end function + end function -end class \ No newline at end of file + end class +end namespace \ No newline at end of file diff --git a/src/source/TestRunner.bs b/src/source/TestRunner.bs index 6735a541..55ed123d 100644 --- a/src/source/TestRunner.bs +++ b/src/source/TestRunner.bs @@ -1,214 +1,191 @@ -' /** -' * @module TestRunner -' */ - -' /** -' * @memberof module:TestRunner -' * @name Rooibos_TestRunner -' * @function -' * @description Creates an instance of the test runner -' */ -class TestRunner - public testScene = invalid - public logger = invalid - public nodeContext = invalid - public config = invalid - public testSuites = [] - - public function new(testScene, nodeContext) - m.testScene = testScene - m.nodeContext = nodeContext - - 'bs:disable-next-line - m.config = rooibos_getRuntimeConfig() - - if m.config = invalid or not Common.isAssociativeArray(m.config) - ? "WARNING : specified config is invalid - using default" - m.config = { - showOnlyFailures: false - failFast: false - } - end if - - end function +namespace Rooibos + ' /** + ' * @module TestRunner + ' */ ' /** ' * @memberof module:TestRunner - ' * @name Run + ' * @name Rooibos_TestRunner ' * @function - ' * @instance - ' * @description Executes all tests for a project, as per the config + ' * @description Creates an instance of the test runner ' */ - public function run() - if type(rooibos_getTestSuitesForProject) <> "Function" - ? "ERROR! rooibos_getTestSuitesForProject is not found! That looks like you didn't run the bsc plugin." - ? "Please add plugins:['rooibos-roku-vsc-extension-plugin'] to your bsconfig.json file" - return - end if - timer = createObject("roTimespan") - timer.mark() - - m.stats = new Stats() - m.runtimeConfig = new RuntimeConfig() - - for each suiteData in m.runtimeConfig.suites - m.createAndRunTestSuite(suiteData) - - if m.stats.hasFailures = true and m.config.failFast = true - exit for - end if - - end for - - m.stats.time = timer.totalMilliseconds() + class TestRunner + public testScene = invalid + public logger = invalid + public nodeContext = invalid + public config = invalid + public testSuites = [] - logger = new TestLogger(m) - logger.printStats() + public function new(testScene, nodeContext) + m.testScene = testScene + m.nodeContext = nodeContext - if Common.isFunction(RBS_reportCodeCoverage) 'bs:disable-next-line - RBS_reportCodeCoverage() - - if m.config.printLcov = true - Coverage.printLCovInfo() + m.config = rooibos_getRuntimeConfig() + + if m.config = invalid or not Rooibos.Common.isAssociativeArray(m.config) + ? "WARNING : specified config is invalid - using default" + m.config = { + showOnlyFailures: false + failFast: false + } end if - end if - m.sendHomeKeypress() - end function - - public function runInNodeMode(nodeTestName) - if type(rooibos_getTestSuitesForProject) <> "Function" - ? "ERROR! rooibos_getTestSuitesForProject is not found! That looks like you didn't run the bsc plugin." - ? "Please add plugins:['rooibos-roku-vsc-extension-plugin'] to your bsconfig.json file" - return invalid - end if - m.runtimeConfig = new RuntimeConfig() - - for each suiteData in m.runtimeConfig.suites - if suiteData.name = nodeTestName - testSuite = suiteData.constructor(suiteData, m.runtimeConfig.hasSoloTests, m.nodeContext) - if testSuite <> invalid - testSuite.run() - return { - stats: testSuite.stats - tests: testSuite.tests - } + end function + + ' /** + ' * @memberof module:TestRunner + ' * @name Run + ' * @function + ' * @instance + ' * @description Executes all tests for a project, as per the config + ' */ + public function run() + if type(rooibos_getTestSuitesForProject) <> "Function" + ? "ERROR! rooibos_getTestSuitesForProject is not found! That looks like you didn't run the bsc plugin." + ? "Please add plugins:['rooibos-roku-vsc-extension-plugin'] to your bsconfig.json file" + return + end if + timer = createObject("roTimespan") + timer.mark() + + m.stats = new Stats() + m.runtimeConfig = new RuntimeConfig() + + suiteNames = m.getGlobalScopeTestSuitesNames() + includedSuites = [] + for each name in suiteNames + suiteClass = m.getTestSuiteClassWithName(name) + testSuite = invalid + if suiteClass <> invalid + testSuite = suiteClass(nodeContext) + m.runTestSuite(testSuite) + if m.stats.hasFailures = true and m.config.failFast = true + exit for + end if else - ? "[ERROR] could not create test suite " ; suiteData.name ; " with class " ; suiteData.constructor + ? "ERROR! coudl not create test for suite : "; name end if - end if - end for + end for - ? "ERROR! executing node test " + m.nodeTestName + " was unsuccesful." + m.stats.time = timer.totalMilliseconds() - return invalid - end function + logger = new TestLogger(m) + logger.printStats() + + if Rooibos.Common.isFunction(RBS_reportCodeCoverage) + 'bs:disable-next-line + RBS_reportCodeCoverage() - private function createAndRunTestSuite(suiteData) as void - if m.runtimeConfig.hasSoloTests = true - if suiteData.hasSoloTests <> true - if m.config.logLevel = 2 - ? "TestSuite " ; suiteData.name ; " Is filtered because it has no solo tests" + if m.config.printLcov = true + Coverage.printLCovInfo() end if - return + end if + m.sendHomeKeypress() + end function + + public function runInNodeMode(nodeTestName) + if type(rooibos_getTestSuitesForProject) <> "Function" + ? "ERROR! rooibos_getTestSuitesForProject is not found! That looks like you didn't run the bsc plugin." + ? "Please add plugins:['rooibos-roku-vsc-extension-plugin'] to your bsconfig.json file" + return invalid end if - else if m.runtimeConfig.hasSoloSuites - if suiteData.isSolo <> true - if m.config.logLevel = 2 - ? "TestSuite " ; suiteData.name ; " Is filtered due to solo flag" - end if + m.runtimeConfig = new RuntimeConfig() + suiteClass = m.getTestSuiteClassWithName(nodeTestName) + testSuite = invalid - return + if suiteClass <> invalid + testSuite = suiteClass(m.top) end if - end if - if suiteData.isIgnored = true - if m.config.logLevel = 2 - ? "Ignoring TestSuite " ; suiteData.name ; " Due to Ignore flag" + if testSuite <> invalid + testSuite.run() + return { + stats: testSuite.stats + tests: testSuite.tests + } + else + ? "[ERROR] could not create test suite " ; nodeTestName end if - m.stats.ignoredCount++ - m.stats.ignoredTestNames.push("|-" + suiteData.name + " [WHOLE SUITE]") + ? "ERROR! executing node test " + nodeTestName + " was unsuccesful." - return - end if - ? "" - ? Common.fillText("> SUITE: " + suiteData.name, ">", 80) + return invalid + end function - testSuite = suiteData.constructor(suiteData, m.runtimeConfig.hasSoloTests, m.nodeContext) - m.testSuites.push(testSuite) + private function runTestSuite(testSuite) as void + ? "" + ? Rooibos.Common.fillText("> SUITE: " + testSuite.name, ">", 80) - if testSuite.hasIgnoredTests - m.stats.ignoredTestNames.push("|-" + testSuite.name) - end if + m.testSuites.push(testSuite) - if testSuite.isNodeTest - m.runNodeTest(testSuite) - else - testSuite.run() - end if + if testSuite.isNodeTest + m.runNodeTest(testSuite) + else + testSuite.run() + end if - m.stats.merge(testSuite.stats) + m.stats.merge(testSuite.stats) - end function + end function - private function runNodeTest(testSuite) as void - if testSuite.nodeName <> "" - ? " +++++RUNNING NODE TEST" - ? " node type is " ; testSuite.nodeName + private function runNodeTest(testSuite) as void + if testSuite.nodeName <> "" + ? " +++++RUNNING NODE TEST" + ? " node type is " ; testSuite.nodeName - node = m.testScene.callFunc("rooibos_createTestNode", testSuite.nodeName) + node = m.testScene.callFunc("rooibos_createTestNode", testSuite.nodeName) - if type(node) = "roSGNode" and node.subType() = testSuite.nodeName - nodeResults = node.callFunc("rooibos_runNodeTestSuite", suiteData.name, m.config) - if nodeResults <> invalid - testSuite.stats = nodeResults.stats - testSuite.testCases = nodeResults.testCases + if type(node) = "roSGNode" and node.subType() = testSuite.nodeName + nodeResults = node.callFunc("rooibos_runNodeTestSuite", testSuite.name, m.config) + if nodeResults <> invalid + testSuite.stats = nodeResults.stats + testSuite.testCases = nodeResults.testCases + else + ? " ERROR! The node "; testSuite.nodeName; " did not return a result from from the rooibos_runNodeTestSuite method. This usually means you are not importing rooibos.brs and the required test file. Please refer to : https://github.com/georgejecook/rooibos/blob/master/docs/index.md#testing-scenegraph-nodes" + end if + m.testScene.removeChild(node) + return else - ? " ERROR! The node "; testSuite.nodeName; " did not return a result from from the rooibos_runNodeTestSuite method. This usually means you are not importing rooibos.brs and the required test file. Please refer to : https://github.com/georgejecook/rooibos/blob/master/docs/index.md#testing-scenegraph-nodes" + ? " ERROR!! - could not create node required to execute tests for " ; testSuite.name + ? " Node of type " ; testSuite.nodeName ; " was not found/could not be instantiated" end if - m.testScene.removeChild(node) - return else - ? " ERROR!! - could not create node required to execute tests for " ; suiteData.name - ? " Node of type " ; testSuite.nodeName ; " was not found/could not be instantiated" + ? " ERROR!! - could not create node required to execute tests for " ; testSuite.name + ? " No node type was provided" end if - else - ? " ERROR!! - could not create node required to execute tests for " ; suiteData.name - ? " No node type was provided" - end if - testSuite.stats.hasFailures = true - testSuite.failedCount += testSuite.testsData.count() - end function + testSuite.stats.hasFailures = true + testSuite.failedCount += testSuite.testsData.count() + end function - private function sendHomeKeypress() - ut = createObject("roUrlTransfer") - ut.SetUrl("http://localhost:8060/keypress/Home") - ut.PostFromString("") - end function + private function sendHomeKeypress() + ut = createObject("roUrlTransfer") + ut.SetUrl("http://localhost:8060/keypress/Home") + ut.PostFromString("") + end function -end class + end class -'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -'++ This code is called inside of the node -'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '++ This code is called inside of the node + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -function createTestNode(nodeType) as object - node = createObject("roSGNode", nodeType) + function createTestNode(nodeType) as object + node = createObject("roSGNode", nodeType) - if type(node) = "roSGNode" and node.subType() = nodeType - m.top.AppendChild(node) - return node - else - ? " Error creating test node of type " ; nodeType - return invalid - end if -end function + if type(node) = "roSGNode" and node.subType() = nodeType + m.top.AppendChild(node) + return node + else + ? " Error creating test node of type " ; nodeType + return invalid + end if + end function -function runNodeTestSuite(name) - nodeRunner = new TestRunner(m.top.getScene(), m) - return nodeRunner.runInNodeMode(name) -end function \ No newline at end of file + function runNodeTestSuite(name) + nodeRunner = new TestRunner(m.top.getScene(), m) + return nodeRunner.runInNodeMode(name) + end function +end namespace \ No newline at end of file diff --git a/src/source/framework.bs b/src/source/framework.bs deleted file mode 100644 index d2282842..00000000 --- a/src/source/framework.bs +++ /dev/null @@ -1,11 +0,0 @@ -' import "pkg:/source/roku_modules/rooibos/BaseTestSuite.brs" -' import "pkg:/source/roku_modules/rooibos/CommonUtils.brs" -' import "pkg:/source/roku_modules/rooibos/Coverage.brs" -' import "pkg:/source/roku_modules/rooibos/Matchers.brs" -' import "pkg:/source/roku_modules/rooibos/Rooibos.brs" -' import "pkg:/source/roku_modules/rooibos/RuntimeConfig.brs" -' import "pkg:/source/roku_modules/rooibos/Stats.brs" -' import "pkg:/source/roku_modules/rooibos/Test.brs" -' import "pkg:/source/roku_modules/rooibos/TestLogger.brs" -' import "pkg:/source/roku_modules/rooibos/TestRunner.brs" -' import "pkg:/source/roku_modules/rooibos/TestResult.brs" \ No newline at end of file diff --git a/src/source/scratch.bs b/src/source/scratch.bs new file mode 100644 index 00000000..d4b4cf2d --- /dev/null +++ b/src/source/scratch.bs @@ -0,0 +1,1611 @@ +class wrapper + override function getTestSuiteData() + return { + name: "Rooibos assertion tests" + isSolo: false + isIgnored: false + filePath: "source/Assertion.spec.bs" + valid: true + hasFailures: undefined + hasSoloTests: undefined + hasIgnoredTests: false + hasSoloGroups: undefined + setupFunctionName: "" + tearDownFunctionName: "" + beforeEachFunctionName: "" + afterEachFunctionName: "" + isNodeTest: undefined + nodeName: "" + testGroups: [ + { + name: "tests basic assertions" + isSolo: false + isIgnored: false + filename: "source/Assertion.spec.bs" + setupFunctionName: "" + tearDownFunctionName: "" + beforeEachFunctionName: "" + afterEachFunctionName: "" + testCases: [ + { + isSolo: false + funcName: "test_fail" + isIgnored: false + isParamTest: false + name: "Fail" + lineNumber: 10 + paramLineNumber: 0 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [] + paramTestIndex: 0 + expectedNumberOfParams: 0 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertTrue" + isIgnored: false + isParamTest: false + name: "param.text0" + lineNumber: 28 + paramLineNumber: 22 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [true, true] + paramTestIndex: 0 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertTrue" + isIgnored: false + isParamTest: false + name: "param.text1" + lineNumber: 28 + paramLineNumber: 23 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [false, false] + paramTestIndex: 1 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertTrue" + isIgnored: false + isParamTest: false + name: "param.text2" + lineNumber: 28 + paramLineNumber: 24 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [invalid, false] + paramTestIndex: 2 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertTrue" + isIgnored: false + isParamTest: false + name: "param.text3" + lineNumber: 28 + paramLineNumber: 25 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [0, false] + paramTestIndex: 3 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertTrue" + isIgnored: false + isParamTest: false + name: "param.text4" + lineNumber: 28 + paramLineNumber: 26 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [1, false] + paramTestIndex: 4 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertTrue" + isIgnored: false + isParamTest: false + name: "param.text5" + lineNumber: 28 + paramLineNumber: 27 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: ["test", false] + paramTestIndex: 5 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertFalse" + isIgnored: false + isParamTest: false + name: "param.text0" + lineNumber: 45 + paramLineNumber: 39 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [false, true] + paramTestIndex: 0 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertFalse" + isIgnored: false + isParamTest: false + name: "param.text1" + lineNumber: 45 + paramLineNumber: 40 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [true, false] + paramTestIndex: 1 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertFalse" + isIgnored: false + isParamTest: false + name: "param.text2" + lineNumber: 45 + paramLineNumber: 41 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [invalid, false] + paramTestIndex: 2 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertFalse" + isIgnored: false + isParamTest: false + name: "param.text3" + lineNumber: 45 + paramLineNumber: 42 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [0, false] + paramTestIndex: 3 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertFalse" + isIgnored: false + isParamTest: false + name: "param.text4" + lineNumber: 45 + paramLineNumber: 43 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [1, false] + paramTestIndex: 4 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertFalse" + isIgnored: false + isParamTest: false + name: "param.text5" + lineNumber: 45 + paramLineNumber: 44 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: ["test", false] + paramTestIndex: 5 + expectedNumberOfParams: 2 + isParamsValid: true + }] + }, + { + name: "tests AssertArrayContainsAAs" + isSolo: false + isIgnored: false + filename: "source/Assertion.spec.bs" + setupFunctionName: "" + tearDownFunctionName: "" + beforeEachFunctionName: "" + afterEachFunctionName: "" + testCases: [ + { + isSolo: false + funcName: "test_assertArrayContainsAAs_Fail" + isIgnored: false + isParamTest: false + name: "param.text0" + lineNumber: 77 + paramLineNumber: 61 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "one": 1 }], [{ "one": 2 }]] + paramTestIndex: 0 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsAAs_Fail" + isIgnored: false + isParamTest: false + name: "param.text1" + lineNumber: 77 + paramLineNumber: 62 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "one": 1 }], [{ "one": "a" }]] + paramTestIndex: 1 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsAAs_Fail" + isIgnored: false + isParamTest: false + name: "param.text2" + lineNumber: 77 + paramLineNumber: 63 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "one": 1 }], [{}]] + paramTestIndex: 2 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsAAs_Fail" + isIgnored: false + isParamTest: false + name: "param.text3" + lineNumber: 77 + paramLineNumber: 64 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "one": 1 }], [invalid]] + paramTestIndex: 3 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsAAs_Fail" + isIgnored: false + isParamTest: false + name: "param.text4" + lineNumber: 77 + paramLineNumber: 65 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "one": 1 }], []] + paramTestIndex: 4 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsAAs_Fail" + isIgnored: false + isParamTest: false + name: "param.text5" + lineNumber: 77 + paramLineNumber: 66 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "one": 1 }], invalid] + paramTestIndex: 5 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsAAs_Fail" + isIgnored: false + isParamTest: false + name: "param.text6" + lineNumber: 77 + paramLineNumber: 67 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "one": 1 }], [[]]] + paramTestIndex: 6 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsAAs_Fail" + isIgnored: false + isParamTest: false + name: "param.text7" + lineNumber: 77 + paramLineNumber: 68 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "one": 1 }], ["wrong"]] + paramTestIndex: 7 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsAAs_Fail" + isIgnored: false + isParamTest: false + name: "param.text8" + lineNumber: 77 + paramLineNumber: 69 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "one": 1 }], [2]] + paramTestIndex: 8 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsAAs_Fail" + isIgnored: false + isParamTest: false + name: "param.text9" + lineNumber: 77 + paramLineNumber: 70 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "one": "a" }], [{ "one": 1 }]] + paramTestIndex: 9 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsAAs_Fail" + isIgnored: false + isParamTest: false + name: "param.text10" + lineNumber: 77 + paramLineNumber: 71 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "two": 1 }], [{ "one": 1 }]] + paramTestIndex: 10 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsAAs_Fail" + isIgnored: false + isParamTest: false + name: "param.text11" + lineNumber: 77 + paramLineNumber: 72 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[invalid], [{ "one": 1 }]] + paramTestIndex: 11 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsAAs_Fail" + isIgnored: false + isParamTest: false + name: "param.text12" + lineNumber: 77 + paramLineNumber: 73 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [invalid, [{ "one": 1 }]] + paramTestIndex: 12 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsAAs_Fail" + isIgnored: false + isParamTest: false + name: "param.text13" + lineNumber: 77 + paramLineNumber: 74 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "one": 1, "two": 2 }], [{ "one": "1" }]] + paramTestIndex: 13 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsAAs_Fail" + isIgnored: false + isParamTest: false + name: "param.text14" + lineNumber: 77 + paramLineNumber: 75 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "one": 1 }, { "two": 2 }], [{ "one": "1" }, { "two": "a" }]] + paramTestIndex: 14 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsAAs_Fail" + isIgnored: false + isParamTest: false + name: "param.text15" + lineNumber: 77 + paramLineNumber: 76 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "one": 1 }, { "two": 2 }], [{ "a": 1 }, { "a": 1 }, { "a": 1 }]] + paramTestIndex: 15 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsAAs_Pass" + isIgnored: false + isParamTest: false + name: "param.text0" + lineNumber: 97 + paramLineNumber: 90 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[], []] + paramTestIndex: 0 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsAAs_Pass" + isIgnored: false + isParamTest: false + name: "param.text1" + lineNumber: 97 + paramLineNumber: 91 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{}], [{}]] + paramTestIndex: 1 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsAAs_Pass" + isIgnored: false + isParamTest: false + name: "param.text2" + lineNumber: 97 + paramLineNumber: 92 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "one": 1 }], [{ "one": 1 }]] + paramTestIndex: 2 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsAAs_Pass" + isIgnored: false + isParamTest: false + name: "param.text3" + lineNumber: 97 + paramLineNumber: 93 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "one": 1, "two": 2 }], [{ "one": 1, "two": 2 }]] + paramTestIndex: 3 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsAAs_Pass" + isIgnored: false + isParamTest: false + name: "param.text4" + lineNumber: 97 + paramLineNumber: 94 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "one": 1, "two": 2 }], [{ "two": 2, "one": 1 }]] + paramTestIndex: 4 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsAAs_Pass" + isIgnored: false + isParamTest: false + name: "param.text5" + lineNumber: 97 + paramLineNumber: 95 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "one": 1, "two": 2 }, { "one": 1 }], [{ "one": 1 }, { "two": 2, "one": 1 }]] + paramTestIndex: 5 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsAAs_Pass" + isIgnored: false + isParamTest: false + name: "param.text6" + lineNumber: 97 + paramLineNumber: 96 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "one": 1, "two": 2 }, { "one": 1 }, { "three": 3 }], [{ "one": 1 }, { "three": 3 }, { "two": 2, "one": 1 }]] + paramTestIndex: 6 + expectedNumberOfParams: 2 + isParamsValid: true + }] + }, + { + name: "tests global is present on testSuite" + isSolo: false + isIgnored: false + filename: "source/Assertion.spec.bs" + setupFunctionName: "" + tearDownFunctionName: "" + beforeEachFunctionName: "" + afterEachFunctionName: "" + testCases: [ + { + isSolo: false + funcName: "test_assertGlobalIsPassedIntoTest" + isIgnored: false + isParamTest: false + name: "global is in test" + lineNumber: 123 + paramLineNumber: 0 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [] + paramTestIndex: 0 + expectedNumberOfParams: 0 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertGlobalIsPassedInto_beforeEach_and_afterEach" + isIgnored: false + isParamTest: false + name: "global is in before each and after each" + lineNumber: 128 + paramLineNumber: 0 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [] + paramTestIndex: 0 + expectedNumberOfParams: 0 + isParamsValid: true + }] + }, + { + name: "tests AssertArrayContainsOnlyValuesOfType" + isSolo: false + isIgnored: false + filename: "source/Assertion.spec.bs" + setupFunctionName: "" + tearDownFunctionName: "" + beforeEachFunctionName: "" + afterEachFunctionName: "" + testCases: [ + { + isSolo: false + funcName: "test_assertArrayContainsOnlyValuesOfType_Pass" + isIgnored: false + isParamTest: false + name: "param.text0" + lineNumber: 144 + paramLineNumber: 139 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [["one", "two", "three"], "String"] + paramTestIndex: 0 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsOnlyValuesOfType_Pass" + isIgnored: false + isParamTest: false + name: "param.text1" + lineNumber: 144 + paramLineNumber: 140 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[1, 2, 3], "Integer"] + paramTestIndex: 1 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsOnlyValuesOfType_Pass" + isIgnored: false + isParamTest: false + name: "param.text2" + lineNumber: 144 + paramLineNumber: 141 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[true, true, false], "Boolean"] + paramTestIndex: 2 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsOnlyValuesOfType_Pass" + isIgnored: false + isParamTest: false + name: "param.text3" + lineNumber: 144 + paramLineNumber: 142 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[[true, true], [false, false]], "Array"] + paramTestIndex: 3 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsOnlyValuesOfType_Pass" + isIgnored: false + isParamTest: false + name: "param.text4" + lineNumber: 144 + paramLineNumber: 143 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "test": 1 }, { "test": 1 }], "AssociativeArray"] + paramTestIndex: 4 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsOnlyValuesOfType_Fail" + isIgnored: false + isParamTest: false + name: "param.text0" + lineNumber: 167 + paramLineNumber: 156 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [["one", 2, "three"], "String"] + paramTestIndex: 0 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsOnlyValuesOfType_Fail" + isIgnored: false + isParamTest: false + name: "param.text1" + lineNumber: 167 + paramLineNumber: 157 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[1, "two", 3], "Integer"] + paramTestIndex: 1 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsOnlyValuesOfType_Fail" + isIgnored: false + isParamTest: false + name: "param.text2" + lineNumber: 167 + paramLineNumber: 158 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[true, "true", false], "Boolean"] + paramTestIndex: 2 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsOnlyValuesOfType_Fail" + isIgnored: false + isParamTest: false + name: "param.text3" + lineNumber: 167 + paramLineNumber: 159 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[[true, true], false, false], "Array"] + paramTestIndex: 3 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsOnlyValuesOfType_Fail" + isIgnored: false + isParamTest: false + name: "param.text4" + lineNumber: 167 + paramLineNumber: 160 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "test": 1 }, "notAA"], "AssociativeArray"] + paramTestIndex: 4 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsOnlyValuesOfType_Fail" + isIgnored: false + isParamTest: false + name: "param.text5" + lineNumber: 167 + paramLineNumber: 161 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [["one", "two", "three"], "UnknownType"] + paramTestIndex: 5 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsOnlyValuesOfType_Fail" + isIgnored: false + isParamTest: false + name: "param.text6" + lineNumber: 167 + paramLineNumber: 162 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [["one", "two", "three"], "Integer"] + paramTestIndex: 6 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsOnlyValuesOfType_Fail" + isIgnored: false + isParamTest: false + name: "param.text7" + lineNumber: 167 + paramLineNumber: 163 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[1, 2, 3], "String"] + paramTestIndex: 7 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsOnlyValuesOfType_Fail" + isIgnored: false + isParamTest: false + name: "param.text8" + lineNumber: 167 + paramLineNumber: 164 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[true, true, false], "String"] + paramTestIndex: 8 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsOnlyValuesOfType_Fail" + isIgnored: false + isParamTest: false + name: "param.text9" + lineNumber: 167 + paramLineNumber: 165 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[[true, true], [false, false]], "AssociativeArray"] + paramTestIndex: 9 + expectedNumberOfParams: 2 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertArrayContainsOnlyValuesOfType_Fail" + isIgnored: false + isParamTest: false + name: "param.text10" + lineNumber: 167 + paramLineNumber: 166 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "test": 1 }, { "test": 1 }], "Array"] + paramTestIndex: 10 + expectedNumberOfParams: 2 + isParamsValid: true + }] + }, + { + name: "tests white spaces work with annotations" + isSolo: false + isIgnored: false + filename: "source/Assertion.spec.bs" + setupFunctionName: "" + tearDownFunctionName: "" + beforeEachFunctionName: "" + afterEachFunctionName: "" + testCases: [ + { + isSolo: false + funcName: "test_whiteSpacing" + isIgnored: false + isParamTest: false + name: "comments between tests" + lineNumber: 190 + paramLineNumber: 0 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [] + paramTestIndex: 0 + expectedNumberOfParams: 0 + isParamsValid: true + }] + }, + { + name: "tests AssertNotEmpty" + isSolo: false + isIgnored: false + filename: "source/Assertion.spec.bs" + setupFunctionName: "" + tearDownFunctionName: "" + beforeEachFunctionName: "" + afterEachFunctionName: "" + testCases: [ + { + isSolo: false + funcName: "test_assertNotEmpty_Pass" + isIgnored: false + isParamTest: false + name: "param.text0" + lineNumber: 221 + paramLineNumber: 214 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [["one", "two", "three"]] + paramTestIndex: 0 + expectedNumberOfParams: 1 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertNotEmpty_Pass" + isIgnored: false + isParamTest: false + name: "param.text1" + lineNumber: 221 + paramLineNumber: 215 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[1, 2, 3]] + paramTestIndex: 1 + expectedNumberOfParams: 1 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertNotEmpty_Pass" + isIgnored: false + isParamTest: false + name: "param.text2" + lineNumber: 221 + paramLineNumber: 216 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[true]] + paramTestIndex: 2 + expectedNumberOfParams: 1 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertNotEmpty_Pass" + isIgnored: false + isParamTest: false + name: "param.text3" + lineNumber: 221 + paramLineNumber: 217 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[[true, true], [false, false]]] + paramTestIndex: 3 + expectedNumberOfParams: 1 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertNotEmpty_Pass" + isIgnored: false + isParamTest: false + name: "param.text4" + lineNumber: 221 + paramLineNumber: 218 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "test": 1 }]] + paramTestIndex: 4 + expectedNumberOfParams: 1 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertNotEmpty_Pass" + isIgnored: false + isParamTest: false + name: "param.text5" + lineNumber: 221 + paramLineNumber: 219 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: ["not empty"] + paramTestIndex: 5 + expectedNumberOfParams: 1 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertNotEmpty_Pass" + isIgnored: false + isParamTest: false + name: "param.text6" + lineNumber: 221 + paramLineNumber: 220 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[invalid]] + paramTestIndex: 6 + expectedNumberOfParams: 1 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertNotEmpty_Fail" + isIgnored: false + isParamTest: false + name: "param.text0" + lineNumber: 238 + paramLineNumber: 233 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [invalid] + paramTestIndex: 0 + expectedNumberOfParams: 1 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertNotEmpty_Fail" + isIgnored: false + isParamTest: false + name: "param.text1" + lineNumber: 238 + paramLineNumber: 234 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[]] + paramTestIndex: 1 + expectedNumberOfParams: 1 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertNotEmpty_Fail" + isIgnored: false + isParamTest: false + name: "param.text2" + lineNumber: 238 + paramLineNumber: 235 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [{}] + paramTestIndex: 2 + expectedNumberOfParams: 1 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertNotEmpty_Fail" + isIgnored: false + isParamTest: false + name: "param.text3" + lineNumber: 238 + paramLineNumber: 236 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [1] + paramTestIndex: 3 + expectedNumberOfParams: 1 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertNotEmpty_Fail" + isIgnored: false + isParamTest: false + name: "param.text4" + lineNumber: 238 + paramLineNumber: 237 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [""] + paramTestIndex: 4 + expectedNumberOfParams: 1 + isParamsValid: true + }] + }, + { + name: "tests AssertEmpty" + isSolo: false + isIgnored: false + filename: "source/Assertion.spec.bs" + setupFunctionName: "" + tearDownFunctionName: "" + beforeEachFunctionName: "" + afterEachFunctionName: "" + testCases: [ + { + isSolo: false + funcName: "test_assertEmpty_Pass" + isIgnored: false + isParamTest: false + name: "param.text0" + lineNumber: 257 + paramLineNumber: 254 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[]] + paramTestIndex: 0 + expectedNumberOfParams: 1 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertEmpty_Pass" + isIgnored: false + isParamTest: false + name: "param.text1" + lineNumber: 257 + paramLineNumber: 255 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [{}] + paramTestIndex: 1 + expectedNumberOfParams: 1 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertEmpty_Pass" + isIgnored: false + isParamTest: false + name: "param.text2" + lineNumber: 257 + paramLineNumber: 256 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [""] + paramTestIndex: 2 + expectedNumberOfParams: 1 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertEmpty_Fail" + isIgnored: false + isParamTest: false + name: "param.text0" + lineNumber: 278 + paramLineNumber: 269 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [1] + paramTestIndex: 0 + expectedNumberOfParams: 1 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertEmpty_Fail" + isIgnored: false + isParamTest: false + name: "param.text1" + lineNumber: 278 + paramLineNumber: 270 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [invalid] + paramTestIndex: 1 + expectedNumberOfParams: 1 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertEmpty_Fail" + isIgnored: false + isParamTest: false + name: "param.text2" + lineNumber: 278 + paramLineNumber: 271 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [["one", "two", "three"]] + paramTestIndex: 2 + expectedNumberOfParams: 1 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertEmpty_Fail" + isIgnored: false + isParamTest: false + name: "param.text3" + lineNumber: 278 + paramLineNumber: 272 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[1, 2, 3]] + paramTestIndex: 3 + expectedNumberOfParams: 1 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertEmpty_Fail" + isIgnored: false + isParamTest: false + name: "param.text4" + lineNumber: 278 + paramLineNumber: 273 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[true]] + paramTestIndex: 4 + expectedNumberOfParams: 1 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertEmpty_Fail" + isIgnored: false + isParamTest: false + name: "param.text5" + lineNumber: 278 + paramLineNumber: 274 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[[true, true], [false, false]]] + paramTestIndex: 5 + expectedNumberOfParams: 1 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertEmpty_Fail" + isIgnored: false + isParamTest: false + name: "param.text6" + lineNumber: 278 + paramLineNumber: 275 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[{ "test": 1 }]] + paramTestIndex: 6 + expectedNumberOfParams: 1 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertEmpty_Fail" + isIgnored: false + isParamTest: false + name: "param.text7" + lineNumber: 278 + paramLineNumber: 276 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: ["not empty"] + paramTestIndex: 7 + expectedNumberOfParams: 1 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_assertEmpty_Fail" + isIgnored: false + isParamTest: false + name: "param.text8" + lineNumber: 278 + paramLineNumber: 277 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [[invalid]] + paramTestIndex: 8 + expectedNumberOfParams: 1 + isParamsValid: true + }] + }, + { + name: "tests expect" + isSolo: false + isIgnored: false + filename: "source/Assertion.spec.bs" + setupFunctionName: "" + tearDownFunctionName: "" + beforeEachFunctionName: "" + afterEachFunctionName: "" + testCases: [ + { + isSolo: false + funcName: "test_expect_multiValues" + isIgnored: false + isParamTest: false + name: "multi return values" + lineNumber: 294 + paramLineNumber: 0 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [] + paramTestIndex: 0 + expectedNumberOfParams: 0 + isParamsValid: true + }] + }, + { + name: "tests expect with overloaded expectOnce" + isSolo: false + isIgnored: false + filename: "source/Assertion.spec.bs" + setupFunctionName: "" + tearDownFunctionName: "" + beforeEachFunctionName: "" + afterEachFunctionName: "" + testCases: [ + { + isSolo: false + funcName: "test_expect_multiExpect_success" + isIgnored: false + isParamTest: false + name: "simple test" + lineNumber: 326 + paramLineNumber: 0 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [] + paramTestIndex: 0 + expectedNumberOfParams: 0 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_expect_multiExpect_success_oneCallsArgsNotTracked" + isIgnored: false + isParamTest: false + name: "can set up multi expects on same method - one invocation with any args" + lineNumber: 357 + paramLineNumber: 0 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [] + paramTestIndex: 0 + expectedNumberOfParams: 0 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_expect_multiExpect_multi_args_success" + isIgnored: false + isParamTest: false + name: "can set up multi expects on same method - multi params" + lineNumber: 388 + paramLineNumber: 0 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [] + paramTestIndex: 0 + expectedNumberOfParams: 0 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_expect_multiExpect_multi_args_others_success" + isIgnored: false + isParamTest: false + name: "multi test, multi params with other expects" + lineNumber: 419 + paramLineNumber: 0 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [] + paramTestIndex: 0 + expectedNumberOfParams: 0 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_expect_multiExpect_multi_args_others_fail" + isIgnored: false + isParamTest: false + name: "multi test, multi params with other expects - fail others" + lineNumber: 458 + paramLineNumber: 0 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [] + paramTestIndex: 0 + expectedNumberOfParams: 0 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_expect_multiExpect_fail" + isIgnored: false + isParamTest: false + name: "param.text0" + lineNumber: 503 + paramLineNumber: 497 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: ["arg1_", "arg2", "arg3"] + paramTestIndex: 0 + expectedNumberOfParams: 3 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_expect_multiExpect_fail" + isIgnored: false + isParamTest: false + name: "param.text1" + lineNumber: 503 + paramLineNumber: 498 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: ["arg1", "arg2", "arg3_"] + paramTestIndex: 1 + expectedNumberOfParams: 3 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_expect_multiExpect_fail" + isIgnored: false + isParamTest: false + name: "param.text2" + lineNumber: 503 + paramLineNumber: 499 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: ["arg1", "arg2_", "arg3"] + paramTestIndex: 2 + expectedNumberOfParams: 3 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_expect_multiExpect_fail" + isIgnored: false + isParamTest: false + name: "param.text3" + lineNumber: 503 + paramLineNumber: 500 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: ["arg1", "arg2_", "arg3"] + paramTestIndex: 3 + expectedNumberOfParams: 3 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_expect_multiExpect_fail" + isIgnored: false + isParamTest: false + name: "param.text4" + lineNumber: 503 + paramLineNumber: 501 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: ["arg1_", "arg2_", "arg3"] + paramTestIndex: 4 + expectedNumberOfParams: 3 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_expect_multiExpect_fail" + isIgnored: false + isParamTest: false + name: "param.text5" + lineNumber: 503 + paramLineNumber: 502 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: ["arg1_", invalid, "arg3"] + paramTestIndex: 5 + expectedNumberOfParams: 3 + isParamsValid: true + }] + }, + { + name: "tests overloaded expectOnce on different objects" + isSolo: false + isIgnored: false + filename: "source/Assertion.spec.bs" + setupFunctionName: "" + tearDownFunctionName: "" + beforeEachFunctionName: "" + afterEachFunctionName: "" + testCases: [ + { + isSolo: false + funcName: "test_expect_multiExpect_differentOnj_success" + isIgnored: false + isParamTest: false + name: "success" + lineNumber: 537 + paramLineNumber: 0 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [] + paramTestIndex: 0 + expectedNumberOfParams: 0 + isParamsValid: true + }, + + { + isSolo: false + funcName: "test_expect_multiExpect_differentOnj_fail" + isIgnored: false + isParamTest: false + name: "fail to match" + lineNumber: 569 + paramLineNumber: 0 + assertIndex: 0 + assertLineNumberMap: {} + rawParams: [] + paramTestIndex: 0 + expectedNumberOfParams: 0 + isParamsValid: true + }] + }] + } + end function + end class + \ No newline at end of file diff --git a/tests/src/source/AssertionTests.bs b/tests/src/source/Assertion.spec.bs similarity index 75% rename from tests/src/source/AssertionTests.bs rename to tests/src/source/Assertion.spec.bs index cb87d439..1b0e53fa 100644 --- a/tests/src/source/AssertionTests.bs +++ b/tests/src/source/Assertion.spec.bs @@ -1,43 +1,17 @@ -import "pkg:/source/roku_modules/rooibos/BaseTestSuite.brs" -'@TestSuite -namespace AssertionTests +namespace Tests - class Basic - public name = "Basic tests" - - override function beforeEach() - - end function - - override function afterEach() - - end function - - '@Test some long english text here - '@Params[true, true] - '@Params[false, false] - '@Params[invalid, false] - '@Params[0, false] - '@Params[1, false] - '@Params["test", false] - function assertTrue(value, expectedAssertResult) as void - - assertResult = m.assertTrue(value) - isFail = m.currentResult.isFail - m.currentResult.Reset() - - m.assertEqual(assertResult, expectedAssertResult, token.start.line) - m.assertEqual(isFail, not expectedAssertResult) - end function - end class - - class BasicAssertions + '@TestSuite Rooibos assertion tests + class AssertionTests extends Rooibos.BaseTestSuite + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests basic assertions + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ '@Test Fail - function fail() as void + function test_fail() as void assertResult = m.Fail("reason") + isFail = m.currentResult.isFail m.currentResult.Reset() @@ -52,7 +26,7 @@ namespace AssertionTests '@Params[0, false] '@Params[1, false] '@Params["test", false] - function assertTrue(value, expectedAssertResult) as void + function test_assertTrue(value, expectedAssertResult) as void assertResult = m.assertTrue(value) isFail = m.currentResult.isFail @@ -69,7 +43,7 @@ namespace AssertionTests '@Params[0, false] '@Params[1, false] '@Params["test", false] - function assertFalse(value, expectedAssertResult) as void + function test_assertFalse(value, expectedAssertResult) as void assertResult = m.assertFalse(value) @@ -79,9 +53,10 @@ namespace AssertionTests m.assertEqual(assertResult, expectedAssertResult) m.assertEqual(isFail, not expectedAssertResult) end function - end class - class AssertArrayContainsAAs + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests AssertArrayContainsAAs + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ '@Test Fail '@Params[[{"one":1}], [{"one":2}]] @@ -100,7 +75,7 @@ namespace AssertionTests '@Params[[{"one":1, "two":2}], [{"one":"1"}] ] '@Params[[{"one":1}, {"two":2}], [{"one":"1"}, {"two":"a"}] ] '@Params[[{"one":1}, {"two":2}], [{"a":1}, {"a":1}, {"a":1}] ] - function assertArrayContainsAAs_Fail(expectedAAs, items) as void + function test_assertArrayContainsAAs_Fail(expectedAAs, items) as void assertResult = m.assertArrayContainsAAs(items, expectedAAs) @@ -120,7 +95,7 @@ namespace AssertionTests '@Params[[{"one":1, "two":2}], [{ "two":2, "one":1}]] '@Params[[{"one":1, "two":2}, {"one":1}], [{"one":1}, { "two":2, "one":1}]] '@Params[[{"one":1, "two":2}, {"one":1}, {"three":3}], [{"one":1}, {"three":3}, { "two":2, "one":1}]] - function assertArrayContainsAAs_Pass(expectedAAs, items) as void + function test_assertArrayContainsAAs_Pass(expectedAAs, items) as void assertResult = m.assertArrayContainsAAs(items, expectedAAs) @@ -130,39 +105,44 @@ namespace AssertionTests m.assertTrue(assertResult) m.assertFalse(isFail) end function - end class - class AssertGlobal + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests global is present on testSuite + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - override function beforeEach() as void + '@BeforeEach + function test_assertGlobal_beforeEach() as void m.beforeEachGlobal = m.global end function - override function afterEach() as void + '@AfterEach + function test_assertGlobal_afterEach() as void m.afterEachGlobal = m.global end function '@Test global is in test - function isPassedIntoTest() as void + function test_assertGlobalIsPassedIntoTest() as void m.assertNotInvalid(m.global) end function '@Test global is in before each and after each - function isPassedInto_beforeEach_and_afterEach() as void + function test_assertGlobalIsPassedInto_beforeEach_and_afterEach() as void m.assertNotInvalid(m.global) m.assertNotInvalid(m.beforeEachGlobal) m.assertNotInvalid(m.afterEachGlobal) end function - end class - class AssertArrayContainsOnlyValuesOfType + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests AssertArrayContainsOnlyValuesOfType + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@Test pass '@Params[["one", "two", "three"], "String"] '@Params[[1, 2, 3], "Integer"] '@Params[[true, true, false], "Boolean"] '@Params[[[true, true], [false, false]], "Array"] '@Params[[{"test":1}, {"test":1}], "AssociativeArray"] - function assertArrayContainsOnlyValuesOfType_Pass(values, typeName) as void + function test_assertArrayContainsOnlyValuesOfType_Pass(values, typeName) as void assertResult = m.assertArrayContainsOnlyValuesOfType(values, typeName) isFail = m.currentResult.isFail @@ -185,7 +165,7 @@ namespace AssertionTests '@Params[[true, true, false], "String"] '@Params[[[true, true], [false, false]], "AssociativeArray"] '@Params[[{"test":1}, {"test":1}], "Array"] - function assertArrayContainsOnlyValuesOfType_Fail(values, typeName) as void + function test_assertArrayContainsOnlyValuesOfType_Fail(values, typeName) as void assertResult = m.assertArrayContainsOnlyValuesOfType(values, typeName) isFail = m.currentResult.isFail @@ -198,16 +178,17 @@ namespace AssertionTests end function - end class - class TestWhiteSpacesWorkWithAnnotations + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests white spaces work with annotations + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 'some comments to 'demonstrate '@Test comments between tests 'that we can have comments 'between functions and tags - function betweenTests() as void + function test_whiteSpacing() as void m.assertTrue(true) end function @@ -222,12 +203,13 @@ namespace AssertionTests 'between functions and tags '@Params[4] - function params(value) as void + function test_whiteSpacing_params(value) as void m.assertTrue(true) end function - end class - class AssertNotEmpty + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests AssertNotEmpty + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ '@Test pass '@Params[["one", "two", "three"]] @@ -237,7 +219,7 @@ namespace AssertionTests '@Params[[{"test":1}]] '@Params["not empty"] '@Params[[invalid]] - function assertNotEmpty_Pass(values) as void + function test_assertNotEmpty_Pass(values) as void assertResult = m.assertNotEmpty(values) isFail = m.currentResult.isFail @@ -254,7 +236,7 @@ namespace AssertionTests '@Params[{}] '@Params[1] '@Params[""] - function assertNotEmpty_Fail(values) as void + function test_assertNotEmpty_Fail(values) as void assertResult = m.assertNotEmpty(values) isFail = m.currentResult.isFail @@ -265,15 +247,15 @@ namespace AssertionTests end function - end class - - class AssertEmpty + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests AssertEmpty + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ '@Test pass '@Params[[]] '@Params[{}] '@Params[""] - function assertEmpty_Pass(values) as void + function test_assertEmpty_Pass(values) as void assertResult = m.assertEmpty(values) isFail = m.currentResult.isFail @@ -294,7 +276,7 @@ namespace AssertionTests '@Params[[{"test":1}]] '@Params["not empty"] '@Params[[invalid]] - function assertEmpty_Fail(values) as void + function test_assertEmpty_Fail(values) as void assertResult = m.assertEmpty(values) isFail = m.currentResult.isFail @@ -305,12 +287,12 @@ namespace AssertionTests end function - end class - - class Expect + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests expect + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ '@Test multi return values - function expect_multiValues() + function test_expect_multiValues() obj = {} m.expect(obj, "mockMethod", 5, invalid, { "multiResult": ["one", 2, invalid, "last"] }, true) @@ -336,12 +318,13 @@ namespace AssertionTests m.assertFalse(isFail) end function - end class - class ExpectOnceOverloaded + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests expect with overloaded expectOnce + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ '@Test simple test - function expect_multiExpect_success() + function test_expect_multiExpect_success() obj = {} arg1 = "arg1" arg2 = "arg2" @@ -372,7 +355,7 @@ namespace AssertionTests '@Test can set up multi expects on same method - one invocation with any args - function expect_multiExpect_success_oneCallsArgsNotTracked() + function test_expect_multiExpect_success_oneCallsArgsNotTracked() obj = {} arg1 = "arg1" arg2 = "arg2" @@ -403,7 +386,7 @@ namespace AssertionTests end function '@Test can set up multi expects on same method - multi params - function expect_multiExpect_multi_args_success() + function test_expect_multiExpect_multi_args_success() obj = {} arg1 = "arg1" arg2 = "arg2" @@ -434,7 +417,7 @@ namespace AssertionTests end function '@Test multi test, multi params with other expects - function expect_multiExpect_multi_args_others_success() + function test_expect_multiExpect_multi_args_others_success() obj = {} arg1 = "arg1" arg2 = "arg2" @@ -473,7 +456,7 @@ namespace AssertionTests end function '@Test multi test, multi params with other expects - fail others - function expect_multiExpect_multi_args_others_fail() + function test_expect_multiExpect_multi_args_others_fail() obj = {} arg1 = "arg1" arg2 = "arg2" @@ -518,7 +501,7 @@ namespace AssertionTests '@Params["arg1", "arg2_", "arg3"] '@Params["arg1_", "arg2_", "arg3"] '@Params["arg1_", invalid, "arg3"] - function expect_multiExpect_fail(call1, call2, call3) + function test_expect_multiExpect_fail(call1, call2, call3) obj = {} arg1 = "arg1" arg2 = "arg2" @@ -546,12 +529,13 @@ namespace AssertionTests m.currentResult.Reset() m.assertTrue(isFail) end function - end class - class ExpectOnceOverLoaded_DifferentObjects + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests overloaded expectOnce on different objects + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ '@Test success - function expect_multiExpect_differentOnj_success() + function test_expect_multiExpect_differentOnj_success() obj = {} obj2 = {} arg1 = "arg1" @@ -583,7 +567,7 @@ namespace AssertionTests end function '@Test fail to match - function expect_multiExpect_differentOnj_fail() + function test_expect_multiExpect_differentOnj_fail() obj = {} obj2 = {} arg1 = "arg1" @@ -613,45 +597,44 @@ namespace AssertionTests m.assertFalse(isFail) end function - end class - - 'ASSERTIONS TO WRITE TESTS FOR! - - 'This is coming soon! - - ' AssertEqual - ' AssertLike - ' AssertNotEqual - ' AssertInvalid - ' AssertNotInvalid - ' AssertAAHasKey - ' AssertAANotHasKey - ' AssertAAHasKeys - ' AssertAANotHasKeys - ' AssertArrayNotContains - ' AssertArrayContainsSubset - ' AssertArrayNotContainsSubsetet - ' AssertArrayCount - ' AssertArrayNotCount - ' AssertArrayContainsOnly - ' AssertType - ' AssertSubType - ' - ' 'Node extensions - ' AssertNodeCount - ' AssertNodeNotCount - ' AssertNodeEmpty - ' AssertNodeNotEmpty - ' AssertNodeContains - ' AssertNodeNotContains - ' AssertNodeContainsFields - ' AssertNodeNotContainsFields - - ' AssertArray - ' AssertAAContainsSubset - ' - ' 'Mocking and stubbing - ' AssertMocks - ' MockFail + 'ASSERTIONS TO WRITE TESTS FOR! + + 'This is coming soon! + + ' AssertEqual + ' AssertLike + ' AssertNotEqual + ' AssertInvalid + ' AssertNotInvalid + ' AssertAAHasKey + ' AssertAANotHasKey + ' AssertAAHasKeys + ' AssertAANotHasKeys + ' AssertArrayNotContains + ' AssertArrayContainsSubset + ' AssertArrayNotContainsSubsetet + ' AssertArrayCount + ' AssertArrayNotCount + ' AssertArrayContainsOnly + ' AssertType + ' AssertSubType + ' + ' 'Node extensions + ' AssertNodeCount + ' AssertNodeNotCount + ' AssertNodeEmpty + ' AssertNodeNotEmpty + ' AssertNodeContains + ' AssertNodeNotContains + ' AssertNodeContainsFields + ' AssertNodeNotContainsFields + + ' AssertArray + ' AssertAAContainsSubset + ' + ' 'Mocking and stubbing + ' AssertMocks + ' MockFail + end class end namespace \ No newline at end of file diff --git a/tests/src/source/Basic.spec.bs b/tests/src/source/Basic.spec.bs new file mode 100644 index 00000000..8b53bd45 --- /dev/null +++ b/tests/src/source/Basic.spec.bs @@ -0,0 +1,83 @@ +namespace Tests + + '@TestSuite Basic tests + class BasicTests extends Rooibos.BaseTestSuite + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests the node context is available for a Node scope function + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@Test + function NodeScope() as void + m.assertNotInvalid(m.node) + Tests.BasicTests.doSomethingInNodeScope(true) + m.assertInvalid(m._isNodeScopeVarSet) + m.assertTrue(m.node._isNodeScopeVarSet) + end function + + function doSomethingInNodeScope(value) + m._isNodeScopeVarSet = value + end function + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests aa's with a mock will not crash the box! + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@Test + function EqualsFixForStubbedAAs() as void + aa = { "test": "value" } + m.expectOnce(aa, "getStubbedObject", [aa]) + + aa.getStubbedObject(aa) + end function + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests aa's that get printed as failures don't crash box + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@Test + function PrintResultsFixForStubbedAAs() as void + aa = { "test": "value" } + bb = { "other": "value" } + m.expectOnce(bb, "getStubbedObject", [aa]) + m.assertEqual(aa, bb) + 'not crashing on printing the wrong output is a pass + m.assertMocks() + m.currentResult.Reset() + end function + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It url in params + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@Test simple + '@Params["http://101.rooibos.com"] + function urlParams(url) as void + m.assertEqual(url, "http://101.rooibos.com") + end function + + '@Test on objects + '@Params[{"url":"http://101.rooibos.com", "othervalue":2}] + '@Params[{url:"http://101.rooibos.com", "othervalue":2}] + '@Params[{url:"http://101.rooibos.com", othervalue:2}] + function urlParams_objects(aa) as void + m.assertEqual(aa.url, "http://101.rooibos.com") + m.assertEqual(aa.othervalue, 2) + end function + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests async tests + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@Test times out + function async_timeout() + item = { "id": "item" } + + m.assertAsyncField(item, "id") + isFail = m.currentResult.isFail + m.currentResult.Reset() + m.assertTrue(isFail) + + end function + end class +end namespace \ No newline at end of file diff --git a/tests/src/source/BasicTests.bs b/tests/src/source/BasicTests.bs deleted file mode 100644 index 7b908204..00000000 --- a/tests/src/source/BasicTests.bs +++ /dev/null @@ -1,81 +0,0 @@ -'@TestSuite [BT] Basic tests -namespace Tests.BasicTests - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests the node context is available for a Node scope function - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test - function NodeScope() as void - m.assertNotInvalid(m.node) - Tests.BasicTests.doSomethingInNodeScope(true) - m.assertInvalid(m._isNodeScopeVarSet) - m.assertTrue(m.node._isNodeScopeVarSet) - end function - - function doSomethingInNodeScope(value) - m._isNodeScopeVarSet = value - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests aa's with a mock will not crash the box! - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test - function EqualsFixForStubbedAAs() as void - aa = { "test": "value" } - m.expectOnce(aa, "getStubbedObject", [aa]) - - aa.getStubbedObject(aa) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests aa's that get printed as failures don't crash box - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test - function PrintResultsFixForStubbedAAs() as void - aa = { "test": "value" } - bb = { "other": "value" } - m.expectOnce(bb, "getStubbedObject", [aa]) - m.assertEqual(aa, bb) - 'not crashing on printing the wrong output is a pass - m.assertMocks() - m.currentResult.Reset() - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It url in params - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test simple - '@Params["http://101.rooibos.com"] - function urlParams(url) as void - m.assertEqual(url, "http://101.rooibos.com") - end function - - '@Test on objects - '@Params[{"url":"http://101.rooibos.com", "othervalue":2}] - '@Params[{url:"http://101.rooibos.com", "othervalue":2}] - '@Params[{url:"http://101.rooibos.com", othervalue:2}] - function urlParams_objects(aa) as void - m.assertEqual(aa.url, "http://101.rooibos.com") - m.assertEqual(aa.othervalue, 2) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests async tests - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test times out - function async_timeout() - item = { "id": "item" } - - m.assertAsyncField(item, "id") - isFail = m.currentResult.isFail - m.currentResult.Reset() - m.assertTrue(isFail) - - end function - -end namespace \ No newline at end of file diff --git a/tests/src/source/Common.spec.bs b/tests/src/source/Common.spec.bs new file mode 100644 index 00000000..d28c7ba3 --- /dev/null +++ b/tests/src/source/Common.spec.bs @@ -0,0 +1,30 @@ +namespace Tests + + '@TestSuite RCMT Common tests + class Common extends Rooibos.BaseTestSuite + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests EqArray + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@Test + '@Params[invalid, [], false] + '@Params[[], invalid, false] + '@Params[invalid, invalid, false] + '@Params[["one", "three"], [], false] + '@Params[[], ["one", "three"], false] + '@Params[[], [], true] + '@Params[["one", "two", "three"], ["one", "three"], false] + '@Params[["one", "two", "three"], ["one", "two", "three"], true] + '@Params[[1, 2, 3], ["one", "two", "three"], false] + '@Params[[1, 2, 3], [1, 2, 3], true] + '@Params[[1, invalid, "3"], [1, invalid, "3"], true] + '@Params[[3, 2, 1], [1, 2, 3], false] + function eqArray_Pass(values, values2, expected) as void + + result = Rooibos.Common.eqArray(values, values2) + m.assertEqual(result, expected) + + end function + + end class +end namespace \ No newline at end of file diff --git a/tests/src/source/CommonTests.bs b/tests/src/source/CommonTests.bs deleted file mode 100644 index 3b25ce99..00000000 --- a/tests/src/source/CommonTests.bs +++ /dev/null @@ -1,27 +0,0 @@ -'@TestSuite RCMT Common tests - -namespace Common - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests EqArray - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test - '@Params[invalid, [], false] - '@Params[[], invalid, false] - '@Params[invalid, invalid, false] - '@Params[["one", "three"], [], false] - '@Params[[], ["one", "three"], false] - '@Params[[], [], true] - '@Params[["one", "two", "three"], ["one", "three"], false] - '@Params[["one", "two", "three"], ["one", "two", "three"], true] - '@Params[[1, 2, 3], ["one", "two", "three"], false] - '@Params[[1, 2, 3], [1, 2, 3], true] - '@Params[[1, invalid, "3"], [1, invalid, "3"], true] - '@Params[[3, 2, 1], [1, 2, 3], false] - function eqArray_Pass(values, values2, expected) as void - - result = Common.eqArray(values, values2) - m.assertEqual(result, expected) - end function - -end namespace \ No newline at end of file diff --git a/tests/src/source/Expect.spec.bs b/tests/src/source/Expect.spec.bs new file mode 100644 index 00000000..1c0e1aa6 --- /dev/null +++ b/tests/src/source/Expect.spec.bs @@ -0,0 +1,58 @@ + +namespace Tests + + '@TestSuite ET ExpectTests + class ExpectTests extends Rooibos.BaseTestSuite + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests bug with expectOnce not matching values + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@Test reported case + '@Params[[52], true] + '@Params[invalid, false] + '@Params[[invalid], true] + '@Params[["42"], true] + '@Params[[42], false] + function expectOnce_valuesBug_reported(expectedValue, expectMockFail) as void + obj = { + foo: function(arg0) : return arg0 : end function + } + + m.ExpectOnce(obj, "foo", expectedValue) + obj.foo(42) + m.isAutoAssertingMocks = false + m.assertMocks() + + isFail = m.currentResult.isFail + m.currentResult.Reset() + m.CleanMocks() + m.assertEqual(isFail, expectMockFail) + end function + + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests mock count limit + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@Test mock count limit at least 25 + function expect_mockCountLimitToBeAtLeast25() as void + + interface = {} + + mockCountLimit = 25 + for i = 1 to mockCountLimit + keyName = StrI(i).trim() + interface[keyName] = function(arg0) : return arg0 : end function + + expectedArg = "a" + expectedReturnValue = "b" + m.ExpectOnce(interface, keyName, [expectedArg], [expectedReturnValue]) + + interface[keyName](expectedArg) + end for + + end function + end class + +end namespace \ No newline at end of file diff --git a/tests/src/source/ExpectTests.bs b/tests/src/source/ExpectTests.bs deleted file mode 100644 index 5cf797d9..00000000 --- a/tests/src/source/ExpectTests.bs +++ /dev/null @@ -1,55 +0,0 @@ -'@TestSuite ET ExpectTests - -namespace Tests.ExpectTests - -'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -'@It tests bug with expectOnce not matching values -'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -'@Test reported case -'@Params[[52], true] -'@Params[invalid, false] -'@Params[[invalid], true] -'@Params[["42"], true] -'@Params[[42], false] -function expectOnce_valuesBug_reported(expectedValue, expectMockFail) as void - obj = { - foo: function(arg0) : return arg0 : end function - } - - m.ExpectOnce(obj, "foo", expectedValue) - obj.foo(42) - m.isAutoAssertingMocks = false - m.assertMocks() - - isFail = m.currentResult.isFail - m.currentResult.Reset() - m.CleanMocks() - m.assertEqual(isFail, expectMockFail) -end function - - -'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -'@It tests mock count limit -'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -'@Test mock count limit at least 25 -function expect_mockCountLimitToBeAtLeast25() as void - - interface = {} - - mockCountLimit = 25 - for i = 1 to mockCountLimit - keyName = StrI(i).trim() - interface[keyName] = function(arg0) : return arg0 : end function - - expectedArg = "a" - expectedReturnValue = "b" - m.ExpectOnce(interface, keyName, [expectedArg], [expectedReturnValue]) - - interface[keyName](expectedArg) - end for - -end function - -end namespace \ No newline at end of file diff --git a/tests/src/source/Matcher.spec.bs b/tests/src/source/Matcher.spec.bs new file mode 100644 index 00000000..6bb3f057 --- /dev/null +++ b/tests/src/source/Matcher.spec.bs @@ -0,0 +1,212 @@ +namespace Tests + '@TestSuite [MT] Matcher Tests + class MatcherTests extends Rooibos.BaseTestSuite + + override function beforeEach() + 'make a mock class + m.myClass = {} + end function + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests a custom matcher + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@Test couple of custom matchers + '@Params[true, false, false] + '@Params[false, true, true] + '@Params[false, false, true] + '@Params[true, true, true] + function matcher_boolean(v1, v2, expectedFail) + returnValue = "notBroken" + m.expectOnce(m.myClass, "doWork", [{ "matcher": match_true }, { "matcher": match_false }], returnValue) + + m.assertEqual(m.myClass.doWork(v1, v2), returnValue) + + m.assertMocks() + isFail = m.currentResult.isFail + + m.currentResult.Reset() + m.assertEqual(isFail, expectedFail) + end function + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests a custom inline matcher + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@Test + '@Params[true, false, false] + '@Params[false, true, true] + '@Params[false, false, true] + '@Params[true, true, true] + function inline_matcher_boolean(v1, v2, expectedFail) + returnValue = "notBroken" + m.expectOnce(m.myClass, "doWork", [{ "matcher": function(value) + return value = true + end function }, { "matcher": function(value) + return value = false + end function }], returnValue) + + m.assertEqual(m.myClass.doWork(v1, v2), returnValue) + + m.assertMocks() + isFail = m.currentResult.isFail + + m.currentResult.Reset() + m.assertEqual(isFail, expectedFail) + end function + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '++ built in matchers + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@Test anyBoolMatcher + '@Params[invalid, true] + '@Params["false", true] + '@Params["true", true] + '@Params[23, true] + '@Params[{}, true] + '@Params[[], true] + '@Params[false, false] + '@Params[true, false] + function matcher_built_in_anyBoolean(v1, expectedFail) + returnValue = "notBroken" + m.expectOnce(m.myClass, "doWork", [m.anyBoolMatcher], returnValue) + + m.assertEqual(m.myClass.doWork(v1), returnValue) + + m.assertMocks() + isFail = m.currentResult.isFail + + m.currentResult.Reset() + m.assertEqual(isFail, expectedFail) + end function + + '@Test anyStringMatcher + '@Params[invalid, true] + '@Params["false", false] + '@Params["true", false] + '@Params[23, true] + '@Params[{}, true] + '@Params[[], true] + '@Params[false, true] + '@Params[true, true] + function matcher_built_in_anyString(v1, expectedFail) + returnValue = "notBroken" + m.expectOnce(m.myClass, "doWork", [m.anyStringMatcher], returnValue) + + m.assertEqual(m.myClass.doWork(v1), returnValue) + + m.assertMocks() + isFail = m.currentResult.isFail + + m.currentResult.Reset() + m.assertEqual(isFail, expectedFail) + end function + + '@Test anyNumberMatcher + '@Params[invalid, true] + '@Params["false", true] + '@Params["true", true] + '@Params[23, false] + '@Params[9, false] + '@Params[0, false] + '@Params[0.2, false] + '@Params[{}, true] + '@Params[[], true] + '@Params[false, true] + '@Params[true, true] + function matcher_built_in_anyNumber(v1, expectedFail) + returnValue = "notBroken" + m.expectOnce(m.myClass, "doWork", [m.anyNumberMatcher], returnValue) + + m.assertEqual(m.myClass.doWork(v1), returnValue) + + m.assertMocks() + isFail = m.currentResult.isFail + + m.currentResult.Reset() + m.assertEqual(isFail, expectedFail) + end function + + '@Test anyAAMatcher + '@Params[invalid, true] + '@Params["false", true] + '@Params["true", true] + '@Params[23, true] + '@Params[{}, false] + '@Params[[], true] + '@Params[false, true] + '@Params[true, true] + function matcher_built_in_anyAA(v1, expectedFail) + returnValue = "notBroken" + m.expectOnce(m.myClass, "doWork", [m.anyAAMatcher], returnValue) + + m.assertEqual(m.myClass.doWork(v1), returnValue) + + m.assertMocks() + isFail = m.currentResult.isFail + + m.currentResult.Reset() + m.assertEqual(isFail, expectedFail) + end function + + '@Test anyArrayMatcher + '@Params[invalid, true] + '@Params["false", true] + '@Params["true", true] + '@Params[23, true] + '@Params[{}, true] + '@Params[[], false] + '@Params[false, true] + '@Params[true, true] + function matcher_built_in_anyArray(v1, expectedFail) + returnValue = "notBroken" + m.expectOnce(m.myClass, "doWork", [m.anyArrayMatcher], returnValue) + + m.assertEqual(m.myClass.doWork(v1), returnValue) + + m.assertMocks() + isFail = m.currentResult.isFail + + m.currentResult.Reset() + m.assertEqual(isFail, expectedFail) + end function + + '@Test anyNodeMatcher + '@Params[invalid, true] + '@Params["false", true] + '@Params["true", true] + '@Params[23, true] + '@Params[{}, true] + '@Params["#RBSNode", false] + '@Params[[], true] + '@Params[false, true] + '@Params[true, true] + function matcher_built_in_anyNode(v1, expectedFail) + returnValue = "notBroken" + m.expectOnce(m.myClass, "doWork", [m.anyNodeMatcher], returnValue) + + m.assertEqual(m.myClass.doWork(v1), returnValue) + + m.assertMocks() + isFail = m.currentResult.isFail + + m.currentResult.Reset() + m.assertEqual(isFail, expectedFail) + end function + + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '++ matchers + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + function match_true(value) + return value = true + end function + + function match_false(value) + return value = false + end function + + end class +end namespace \ No newline at end of file diff --git a/tests/src/source/MatcherTests.bs b/tests/src/source/MatcherTests.bs deleted file mode 100644 index 5abc50fc..00000000 --- a/tests/src/source/MatcherTests.bs +++ /dev/null @@ -1,211 +0,0 @@ -'@TestSuite [MT] Matcher Tests -namespace Tests.MatcherTests - - '@BeforeEach - function beforeEach() - 'make a mock class - m.myClass = {} - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests a custom matcher - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test couple of custom matchers - '@Params[true, false, false] - '@Params[false, true, true] - '@Params[false, false, true] - '@Params[true, true, true] - function matcher_boolean(v1, v2, expectedFail) - returnValue = "notBroken" - m.expectOnce(m.myClass, "doWork", [{ "matcher": match_true }, { "matcher": match_false }], returnValue) - - m.assertEqual(m.myClass.doWork(v1, v2), returnValue) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertEqual(isFail, expectedFail) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests a custom inline matcher - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test - '@Params[true, false, false] - '@Params[false, true, true] - '@Params[false, false, true] - '@Params[true, true, true] - function inline_matcher_boolean(v1, v2, expectedFail) - returnValue = "notBroken" - m.expectOnce(m.myClass, "doWork", [{ "matcher": function(value) - return value = true - end function }, { "matcher": function(value) - return value = false - end function }], returnValue) - - m.assertEqual(m.myClass.doWork(v1, v2), returnValue) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertEqual(isFail, expectedFail) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '++ built in matchers - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test anyBoolMatcher - '@Params[invalid, true] - '@Params["false", true] - '@Params["true", true] - '@Params[23, true] - '@Params[{}, true] - '@Params[[], true] - '@Params[false, false] - '@Params[true, false] - function matcher_built_in_anyBoolean(v1, expectedFail) - returnValue = "notBroken" - m.expectOnce(m.myClass, "doWork", [m.anyBoolMatcher], returnValue) - - m.assertEqual(m.myClass.doWork(v1), returnValue) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertEqual(isFail, expectedFail) - end function - - '@Test anyStringMatcher - '@Params[invalid, true] - '@Params["false", false] - '@Params["true", false] - '@Params[23, true] - '@Params[{}, true] - '@Params[[], true] - '@Params[false, true] - '@Params[true, true] - function matcher_built_in_anyString(v1, expectedFail) - returnValue = "notBroken" - m.expectOnce(m.myClass, "doWork", [m.anyStringMatcher], returnValue) - - m.assertEqual(m.myClass.doWork(v1), returnValue) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertEqual(isFail, expectedFail) - end function - - '@Test anyNumberMatcher - '@Params[invalid, true] - '@Params["false", true] - '@Params["true", true] - '@Params[23, false] - '@Params[9, false] - '@Params[0, false] - '@Params[0.2, false] - '@Params[{}, true] - '@Params[[], true] - '@Params[false, true] - '@Params[true, true] - function matcher_built_in_anyNumber(v1, expectedFail) - returnValue = "notBroken" - m.expectOnce(m.myClass, "doWork", [m.anyNumberMatcher], returnValue) - - m.assertEqual(m.myClass.doWork(v1), returnValue) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertEqual(isFail, expectedFail) - end function - - '@Test anyAAMatcher - '@Params[invalid, true] - '@Params["false", true] - '@Params["true", true] - '@Params[23, true] - '@Params[{}, false] - '@Params[[], true] - '@Params[false, true] - '@Params[true, true] - function matcher_built_in_anyAA(v1, expectedFail) - returnValue = "notBroken" - m.expectOnce(m.myClass, "doWork", [m.anyAAMatcher], returnValue) - - m.assertEqual(m.myClass.doWork(v1), returnValue) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertEqual(isFail, expectedFail) - end function - - '@Test anyArrayMatcher - '@Params[invalid, true] - '@Params["false", true] - '@Params["true", true] - '@Params[23, true] - '@Params[{}, true] - '@Params[[], false] - '@Params[false, true] - '@Params[true, true] - function matcher_built_in_anyArray(v1, expectedFail) - returnValue = "notBroken" - m.expectOnce(m.myClass, "doWork", [m.anyArrayMatcher], returnValue) - - m.assertEqual(m.myClass.doWork(v1), returnValue) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertEqual(isFail, expectedFail) - end function - - '@Test anyNodeMatcher - '@Params[invalid, true] - '@Params["false", true] - '@Params["true", true] - '@Params[23, true] - '@Params[{}, true] - '@Params["#RBSNode", false] - '@Params[[], true] - '@Params[false, true] - '@Params[true, true] - function matcher_built_in_anyNode(v1, expectedFail) - returnValue = "notBroken" - m.expectOnce(m.myClass, "doWork", [m.anyNodeMatcher], returnValue) - - m.assertEqual(m.myClass.doWork(v1), returnValue) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertEqual(isFail, expectedFail) - end function - - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '++ matchers - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - function match_true(value) - return value = true - end function - - function match_false(value) - return value = false - end function - -end namespace \ No newline at end of file diff --git a/tests/src/source/NodeExample.spec.bs b/tests/src/source/NodeExample.spec.bs new file mode 100644 index 00000000..dc25496e --- /dev/null +++ b/tests/src/source/NodeExample.spec.bs @@ -0,0 +1,37 @@ +namespace Tests + '@SGNode NodeExampleTests + '@TestSuite [NET] Node Example Tests + class NodeExampleTests extends Rooibos.BaseTestSuite + override function setup() as void + m.setupThing = "something created during setup" + end function + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests methods present on the node + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + override function beforeEach() as void + m.beforeEachThing = "something created beforeEach" + end function + + '@Test HelloFromNode + function helloFromNode_simple() as void + 'bs:disable-next-line + text = HelloFromNode("georgejecook", 12) + m.AssertEqual(text, "HELLO georgejecook" + " age:" + stri(12)) + end function + + '@Test HelloFromNode with params + '@Params["jon", 40] + '@Params["ringo", 23] + '@Params["ringo", 50] + '@Params["ringo", 24] + '@Params["george", 40] + '@Params["paul", 50] + function helloFromNode_params(name, age) as void + 'bs:disable-next-line + text = HelloFromNode(name, age) + m.AssertEqual(text, "HELLO " + name + " age:" + stri(age)) + end function + end class +end namespace diff --git a/tests/src/source/NodeExampleTests.bs b/tests/src/source/NodeExampleTests.bs deleted file mode 100644 index 820649b5..00000000 --- a/tests/src/source/NodeExampleTests.bs +++ /dev/null @@ -1,39 +0,0 @@ -'@SGNode NodeExampleTests -'@TestSuite [NET] Node Example Tests -namespace Tests.NodeExampleTests - - '@Setup - function setup() as void - m.setupThing = "something created during setup" - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests methods present on the node - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@BeforeEach - function beforeEach() as void - m.beforeEachThing = "something created beforeEach" - end function - - '@Test HelloFromNode - function helloFromNode_simple() as void - 'bs:disable-next-line - text = HelloFromNode("georgejecook", 12) - m.AssertEqual(text, "HELLO georgejecook" + " age:" + stri(12)) - end function - - '@Test HelloFromNode with params - '@Params["jon", 40] - '@Params["ringo", 23] - '@Params["ringo", 50] - '@Params["ringo", 24] - '@Params["george", 40] - '@Params["paul", 50] - function helloFromNode_params(name, age) as void - 'bs:disable-next-line - text = HelloFromNode(name, age) - m.AssertEqual(text, "HELLO " + name + " age:" + stri(age)) - end function - -end namespace diff --git a/tests/src/source/Params.spec.bs b/tests/src/source/Params.spec.bs new file mode 100644 index 00000000..9b33d791 --- /dev/null +++ b/tests/src/source/Params.spec.bs @@ -0,0 +1,36 @@ +namespace Tests + + '@TestSuite PT ParamsTests + class ParamsTest extends Rooibos.BaseTestSuite + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests that nodes are created with RBSNode + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@Test + '@Params["#RBSNode", "ContentNode"] + '@Params["#RBSNode|Group", "Group"] + '@Params["#RBSNode|Label", "Label"] + function nodeDirective(node, expectedNodeType) as void + m.assertSubType(node, expectedNodeType) + end function + + '@Test node parsed as other arg index + '@Params[1, 2, 3, "#RBSNode", "ContentNode"] + '@Params[1, 2, 3, "#RBSNode|Group", "Group"] + '@Params[1, 2, 3, "#RBSNode|Label", "Label"] + function nodeDirective_otherArgs(arg1, arg2, arg3, node, expectedNodeType) as void + m.assertSubType(node, expectedNodeType) + m.assertEqual(arg1, 1) + m.assertEqual(arg2, 2) + m.assertEqual(arg3, 3) + end function + + '@Test does not affect regular params + '@Params["#someValue", "#someValue"] + '@Params[22, 22] + '@Params[[1,2,3], [1,2,3]] + function nodeDirective_noSideEffect(arg1, expectedValue) as void + m.assertEqual(arg1, expectedValue) + end function + end class +end namespace \ No newline at end of file diff --git a/tests/src/source/ParamsTests.bs b/tests/src/source/ParamsTests.bs deleted file mode 100644 index 6d18225b..00000000 --- a/tests/src/source/ParamsTests.bs +++ /dev/null @@ -1,35 +0,0 @@ -'@TestSuite PT ParamsTests -namespace Tests.ParamsTest - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests that nodes are created with RBSNode - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test - '@Params["#RBSNode", "ContentNode"] - '@Params["#RBSNode|Group", "Group"] - '@Params["#RBSNode|Label", "Label"] - function nodeDirective(node, expectedNodeType) as void - m.assertSubType(node, expectedNodeType) - end function - - '@Test node parsed as other arg index - '@Params[1, 2, 3, "#RBSNode", "ContentNode"] - '@Params[1, 2, 3, "#RBSNode|Group", "Group"] - '@Params[1, 2, 3, "#RBSNode|Label", "Label"] - function nodeDirective_otherArgs(arg1, arg2, arg3, node, expectedNodeType) as void - m.assertSubType(node, expectedNodeType) - m.assertEqual(arg1, 1) - m.assertEqual(arg2, 2) - m.assertEqual(arg3, 3) - end function - - '@Test does not affect regular params - '@Params["#someValue", "#someValue"] - '@Params[22, 22] - '@Params[[1,2,3], [1,2,3]] - function nodeDirective_noSideEffect(arg1, expectedValue) as void - m.assertEqual(arg1, expectedValue) - end function - -end namespace \ No newline at end of file diff --git a/tests/src/source/Version.spec.bs b/tests/src/source/Version.spec.bs new file mode 100644 index 00000000..58144d43 --- /dev/null +++ b/tests/src/source/Version.spec.bs @@ -0,0 +1,28 @@ +namespace Tests + + '@TestSuite [VT] Version tests + class VersionTests extends Rooibos.BaseTestSuite + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests versionCompare + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@Test + '@Params["0.1", "0.1", 0] + '@Params["1.0", "1.0", 0] + '@Params["1.0.0", "1.0.0", 0] + '@Params["1.0.1", "1.0.1", 0] + '@Params["0.1", "0.2", -1] + '@Params["1.0", "2.0", -1] + '@Params["1.0.0", "2.0.0", -1] + '@Params["2.0.0", "2.0.1", -1] + '@Params["0.2", "0.1", 1] + '@Params["2.0", "1.0", 1] + '@Params["2.0.0", "1.0.0", 1] + '@Params["2.0.1", "2.0.0", 1] + function versionCompare(v1, v2, expected) as void + m.assertEqual(versionCompare(v1, v2), expected) + end function + + end class +end namespace diff --git a/tests/src/source/VersionTests.bs b/tests/src/source/VersionTests.bs deleted file mode 100644 index 015572f7..00000000 --- a/tests/src/source/VersionTests.bs +++ /dev/null @@ -1,26 +0,0 @@ -'@TestSuite [VT] Version tests - -namespace Tests.VersionTests - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests versionCompare - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test - '@Params["0.1", "0.1", 0] - '@Params["1.0", "1.0", 0] - '@Params["1.0.0", "1.0.0", 0] - '@Params["1.0.1", "1.0.1", 0] - '@Params["0.1", "0.2", -1] - '@Params["1.0", "2.0", -1] - '@Params["1.0.0", "2.0.0", -1] - '@Params["2.0.0", "2.0.1", -1] - '@Params["0.2", "0.1", 1] - '@Params["2.0", "1.0", 1] - '@Params["2.0.0", "1.0.0", 1] - '@Params["2.0.1", "2.0.0", 1] - function versionCompare(v1, v2, expected) as void - m.assertEqual(rooibos_versionCompare(v1, v2), expected) - end function - -end namespace diff --git a/tests/src/source/issue_13_afterEach_not_running.bs b/tests/src/source/issue_13_afterEach_not_running.bs deleted file mode 100644 index 92be8699..00000000 --- a/tests/src/source/issue_13_afterEach_not_running.bs +++ /dev/null @@ -1,51 +0,0 @@ -'@Ignore - only unignore to test compiler works -'@TestSuite [DGNT] Duplicate Group Name Tests - -namespace Tests.AfterEachNotRunning - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It group1 - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test simple - function group1_test() - m.assertTrue(true) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It group2 - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test simple - function group2_test() - m.assertTrue(true) - end function - - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It group2 - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test simple - function group2_dupe_test() - m.assertTrue(true) - end function - - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It group3 - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test simple - function group3_test() - m.assertTrue(true) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It group1 - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test simple - function group1_dupe_test() - m.assertTrue(true) - end function -end namespace \ No newline at end of file diff --git a/tests/src/source/issue_13_afterEach_not_running.spec.bs b/tests/src/source/issue_13_afterEach_not_running.spec.bs new file mode 100644 index 00000000..7830b4ca --- /dev/null +++ b/tests/src/source/issue_13_afterEach_not_running.spec.bs @@ -0,0 +1,54 @@ + +namespace Tests + + '@Ignore - only unignore to test compiler works + '@TestSuite [DGNT] Duplicate Group Name Tests + class AfterEachNotRunning extends Rooibos.BaseTestSuite + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It group1 + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@Test simple + function group1_test() + m.assertTrue(true) + end function + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It group2 + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@Test simple + function group2_test() + m.assertTrue(true) + end function + + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It group2 + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@Test simple + function group2_dupe_test() + m.assertTrue(true) + end function + + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It group3 + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@Test simple + function group3_test() + m.assertTrue(true) + end function + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It group1 + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@Test simple + function group1_dupe_test() + m.assertTrue(true) + end function + end class +end namespace \ No newline at end of file diff --git a/tests/src/source/issue_15_tests_only_on_groups.bs b/tests/src/source/issue_15_tests_only_on_groups.bs deleted file mode 100644 index 1375f8ac..00000000 --- a/tests/src/source/issue_15_tests_only_on_groups.bs +++ /dev/null @@ -1,31 +0,0 @@ -'ADD '@Only ON NEXT LINE TO TEST -'@TestSuite [RBSA] Rooibos before after tests -namespace Tests.OnlyOnGroups - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests one - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test it one - function it_test_one() as void - m.assertTrue(true) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests two - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test it two - function it_test_two() as void - m.assertTrue(true) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 'ADD '@Only ON NEXT LINE TO TEST - '@It tests three - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test it three - function it_test_three() as void - m.assertTrue(true) - end function -end namespace \ No newline at end of file diff --git a/tests/src/source/issue_15_tests_only_on_groups.spec.bs b/tests/src/source/issue_15_tests_only_on_groups.spec.bs new file mode 100644 index 00000000..737aba46 --- /dev/null +++ b/tests/src/source/issue_15_tests_only_on_groups.spec.bs @@ -0,0 +1,33 @@ +namespace Tests + 'ADD '@Only ON NEXT LINE TO TEST + '@TestSuite [RBSA] Rooibos before after tests + class OnlyOnGroups extends Rooibos.BaseTestSuite + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests one + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@Test it one + function it_test_one() as void + m.assertTrue(true) + end function + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests two + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@Test it two + function it_test_two() as void + m.assertTrue(true) + end function + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 'ADD '@Only ON NEXT LINE TO TEST + '@It tests three + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@Test it three + function it_test_three() as void + m.assertTrue(true) + end function + end class +end namespace \ No newline at end of file diff --git a/tests/src/source/issue_5_duplicateGroupNames.bs b/tests/src/source/issue_5_duplicateGroupNames.bs deleted file mode 100644 index ebed3953..00000000 --- a/tests/src/source/issue_5_duplicateGroupNames.bs +++ /dev/null @@ -1,32 +0,0 @@ -'@Ignore - only unignore to test compiler works - remove REMOVE_THIS to test -'@TestSuite [RBSA] REMOVE_THIS Rooibos before after tests -namespace Tests.DuplicateGroupNames - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests before each and after each are running - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@BeforeEach - function beforeEach() as void - ? "!!! Before" - end function - - - '@AfterEach - function afterEach() as void - ? "!!! After" - end function - - '@Test before after - function before_after() as void - - assertResult = m.Fail("reason") - - isFail = m.currentResult.isFail - m.currentResult.Reset() - - m.assertFalse(assertResult) - m.assertTrue(isFail) - end function - -end namespace \ No newline at end of file diff --git a/tests/src/source/issue_5_duplicateGroupNames.spec.bs b/tests/src/source/issue_5_duplicateGroupNames.spec.bs new file mode 100644 index 00000000..0bc1a965 --- /dev/null +++ b/tests/src/source/issue_5_duplicateGroupNames.spec.bs @@ -0,0 +1,34 @@ +namespace Tests + + '@Ignore - only unignore to test compiler works - remove REMOVE_THIS to test + '@TestSuite [RBSA] REMOVE_THIS Rooibos before after tests + class DuplicateGroupNames extends Rooibos.BaseTestSuite + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests before each and after each are running + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@BeforeEach + override function group_beforeEach() as void + ? "!!! Before" + end function + + + '@AfterEach + override function group_afterEach() as void + ? "!!! After" + end function + + '@Test before after + function before_after() as void + + assertResult = m.Fail("reason") + + isFail = m.currentResult.isFail + m.currentResult.Reset() + + m.assertFalse(assertResult) + m.assertTrue(isFail) + end function + + end class +end namespace \ No newline at end of file diff --git a/tests/src/source/main.bs b/tests/src/source/main.bs deleted file mode 100644 index 64c03571..00000000 --- a/tests/src/source/main.bs +++ /dev/null @@ -1,37 +0,0 @@ -sub Main(args as dynamic) - ? "Launching with args " - ? args - m.args = args - - ' if (type(Rooibos__Init) = "Function") then Rooibos__Init(invalid, invalid, invalid, m) - InitScreen() -end sub - - -function InitScreen() as void - 'this will be where you setup your typical roku app - 'it will not be launched when running unit tests - screen = CreateObject("roSGScreen") - m.port = CreateObject("roMessagePort") - screen.setMessagePort(m.port) - - rootScene = screen.CreateScene("MainScene") - rootScene.id = "ROOT" - - screen.show() - - 'do any other stuff here that _must_ be done in main - 'I'm not a fan of that though; but just showing how it would work - rootScene.callFunc("begin", m.args) - - while(true) - msg = wait(0, m.port) - msgType = type(msg) - - if msgType = "roSGScreenEvent" - if msg.isScreenClosed() - return - end if - end if - end while -end function \ No newline at end of file diff --git a/tests/src/source/rooibos-framework.bs b/tests/src/source/rooibos-framework.bs deleted file mode 100644 index 2d709576..00000000 --- a/tests/src/source/rooibos-framework.bs +++ /dev/null @@ -1,11 +0,0 @@ -import "pkg:/source/roku_modules/rooibos/BaseTestSuite.brs" -import "pkg:/source/roku_modules/rooibos/CommonUtils.brs" -import "pkg:/source/roku_modules/rooibos/Coverage.brs" -import "pkg:/source/roku_modules/rooibos/Matchers.brs" -import "pkg:/source/roku_modules/rooibos/Rooibos.brs" -import "pkg:/source/roku_modules/rooibos/RuntimeConfig.brs" -import "pkg:/source/roku_modules/rooibos/Stats.brs" -import "pkg:/source/roku_modules/rooibos/Test.brs" -import "pkg:/source/roku_modules/rooibos/TestLogger.brs" -import "pkg:/source/roku_modules/rooibos/TestRunner.brs" -import "pkg:/source/roku_modules/rooibos/TestResult.brs" \ No newline at end of file diff --git a/tests/src/source/testConfig.json b/tests/src/source/testConfig.json deleted file mode 100644 index 8380fe04..00000000 --- a/tests/src/source/testConfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "logLevel": 1, - "failFast": false, - "showOnlyFailures": true -} diff --git a/tests/src/source/verifyBeforeEachAfterEach.bs b/tests/src/source/verifyBeforeEachAfterEach.bs deleted file mode 100644 index a89004cb..00000000 --- a/tests/src/source/verifyBeforeEachAfterEach.bs +++ /dev/null @@ -1,102 +0,0 @@ -'@TestSuite [BEAER] BeforeEach and AfterEach Running -namespace Tests.VeritfyBeforeEachAfterEach - - '@Setup - function Setup() as void - ? "!!! Setup" - end function - - - '@TearDown - function TearDown() as void - ? "!!! TearDown" - end function - - '@BeforeEach - function BeforeEach() as void - ? "!!! Before" - end function - - - '@AfterEach - function AfterEach() as void - ? "!!! After" - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests group 1 - should have global before/after - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test 1 - function group1_1() as void - m.assertTrue(true) - end function - - '@Test 2 - function group1_2() as void - m.assertTrue(true) - end function - - '@Test 3 - '@Params["a"] - '@Params["b"] - '@Params["c"] - function group1_3(values) as void - m.assertTrue(true) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests group 2 - should have group before after - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@BeforeEach - function group2_BeforeEach() as void - ? "!!! Before GROUP 2" - end function - - - '@AfterEach - function group2_AfterEach() as void - ? "!!! After GROUP 2" - end function - - '@Test 1 - function group2_1() as void - m.assertTrue(true) - end function - - '@Test 2 - function group2_2() as void - m.assertTrue(true) - end function - - '@Test 3 - '@Params["a"] - '@Params["b"] - '@Params["c"] - function group2_3(values) as void - m.assertTrue(true) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests group 3 - should have global before/after - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test 1 - function group3_1() as void - m.assertTrue(true) - end function - - '@Test 2 - function group3_2() as void - m.assertTrue(true) - end function - - '@Test 3 - '@Params["a"] - '@Params["b"] - '@Params["c"] - function group3_3(values) as void - m.assertTrue(true) - end function -end namespace diff --git a/tests/src/source/verifyBeforeEachAfterEach.spec.bs b/tests/src/source/verifyBeforeEachAfterEach.spec.bs new file mode 100644 index 00000000..fdf1f7da --- /dev/null +++ b/tests/src/source/verifyBeforeEachAfterEach.spec.bs @@ -0,0 +1,100 @@ +namespace Tests + + '@TestSuite [BEAER] BeforeEach and AfterEach Running + class VeritfyBeforeEachAfterEach extends Rooibos.BaseTestSuite + + override function Setup() as void + ? "!!! Setup" + end function + + override function TearDown() as void + ? "!!! TearDown" + end function + + override function BeforeEach() as void + ? "!!! Before" + end function + + override function AfterEach() as void + ? "!!! After" + end function + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests group 1 - should have global before/after + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@Test 1 + function group1_1() as void + m.assertTrue(true) + end function + + '@Test 2 + function group1_2() as void + m.assertTrue(true) + end function + + '@Test 3 + '@Params["a"] + '@Params["b"] + '@Params["c"] + function group1_3(values) as void + m.assertTrue(true) + end function + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests group 2 - should have group before after + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@BeforeEach + function group2_BeforeEach() as void + ? "!!! Before GROUP 2" + end function + + + '@AfterEach + function group2_AfterEach() as void + ? "!!! After GROUP 2" + end function + + '@Test 1 + function group2_1() as void + m.assertTrue(true) + end function + + '@Test 2 + function group2_2() as void + m.assertTrue(true) + end function + + '@Test 3 + '@Params["a"] + '@Params["b"] + '@Params["c"] + function group2_3(values) as void + m.assertTrue(true) + end function + + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + '@It tests group 3 - should have global before/after + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + '@Test 1 + function group3_1() as void + m.assertTrue(true) + end function + + '@Test 2 + function group3_2() as void + m.assertTrue(true) + end function + + '@Test 3 + '@Params["a"] + '@Params["b"] + '@Params["c"] + function group3_3(values) as void + m.assertTrue(true) + end function + + end class +end namespace diff --git a/tests/src/tests/AssertionTests.bs b/tests/src/tests/AssertionTests.bs deleted file mode 100644 index 8635150d..00000000 --- a/tests/src/tests/AssertionTests.bs +++ /dev/null @@ -1,637 +0,0 @@ -'@TestSuite [RBSA] Rooibos assertion tests - -namespace Tests.Assertions - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests basic assertions - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test Fail - function fail() as void - - assertResult = m.Fail("reason") - - isFail = m.currentResult.isFail - m.currentResult.Reset() - - m.assertFalse(assertResult) - m.assertTrue(isFail) - end function - - '@Test AssertTrue - '@Params[true, true] - '@Params[false, false] - '@Params[invalid, false] - '@Params[0, false] - '@Params[1, false] - '@Params["test", false] - function assertTrue(value, expectedAssertResult) as void - - assertResult = m.assertTrue(value) - isFail = m.currentResult.isFail - m.currentResult.Reset() - - m.assertEqual(assertResult, expectedAssertResult) - m.assertEqual(isFail, not expectedAssertResult) - end function - - '@Test AssertFalse - '@Params[false, true] - '@Params[true, false] - '@Params[invalid, false] - '@Params[0, false] - '@Params[1, false] - '@Params["test", false] - function assertFalse(value, expectedAssertResult) as void - - assertResult = m.assertFalse(value) - - isFail = m.currentResult.isFail - m.currentResult.Reset() - - m.assertEqual(assertResult, expectedAssertResult) - m.assertEqual(isFail, not expectedAssertResult) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests AssertArrayContainsAAs - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test Fail - '@Params[[{"one":1}], [{"one":2}]] - '@Params[[{"one":1}], [{"one":"a"}]] - '@Params[[{"one":1}], [{}]] - '@Params[[{"one":1}], [invalid]] - '@Params[[{"one":1}], []] - '@Params[[{"one":1}], invalid] - '@Params[[{"one":1}], [[]] ] - '@Params[[{"one":1}], ["wrong"] ] - '@Params[[{"one":1}], [2] ] - '@Params[[{"one":"a"}], [{"one":1}] ] - '@Params[[{"two":1}], [{"one":1}] ] - '@Params[[invalid], [{"one":1}] ] - '@Params[invalid, [{"one":1}] ] - '@Params[[{"one":1, "two":2}], [{"one":"1"}] ] - '@Params[[{"one":1}, {"two":2}], [{"one":"1"}, {"two":"a"}] ] - '@Params[[{"one":1}, {"two":2}], [{"a":1}, {"a":1}, {"a":1}] ] - function assertArrayContainsAAs_Fail(expectedAAs, items) as void - - assertResult = m.assertArrayContainsAAs(items, expectedAAs) - - isFail = m.currentResult.isFail - m.currentResult.Reset() - - m.assertFalse(assertResult) - m.assertTrue(isFail) - end function - - - '@Test pass - '@Params[[], []] - '@Params[[{}], [{}]] - '@Params[[{"one":1}], [{"one":1}]] - '@Params[[{"one":1, "two":2}], [{"one":1, "two":2}]] - '@Params[[{"one":1, "two":2}], [{ "two":2, "one":1}]] - '@Params[[{"one":1, "two":2}, {"one":1}], [{"one":1}, { "two":2, "one":1}]] - '@Params[[{"one":1, "two":2}, {"one":1}, {"three":3}], [{"one":1}, {"three":3}, { "two":2, "one":1}]] - function assertArrayContainsAAs_Pass(expectedAAs, items) as void - - assertResult = m.assertArrayContainsAAs(items, expectedAAs) - - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertTrue(assertResult) - m.assertFalse(isFail) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests global is present on testSuite - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@BeforeEach - function assertGlobal_beforeEach() as void - m.beforeEachGlobal = m.global - end function - - '@AfterEach - function assertGlobal_afterEach() as void - m.afterEachGlobal = m.global - end function - - '@Test global is in test - function assertGlobalIsPassedIntoTest() as void - m.assertNotInvalid(m.global) - end function - - '@Test global is in before each and after each - function assertGlobalIsPassedInto_beforeEach_and_afterEach() as void - m.assertNotInvalid(m.global) - m.assertNotInvalid(m.beforeEachGlobal) - m.assertNotInvalid(m.afterEachGlobal) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests AssertArrayContainsOnlyValuesOfType - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test pass - '@Params[["one", "two", "three"], "String"] - '@Params[[1, 2, 3], "Integer"] - '@Params[[true, true, false], "Boolean"] - '@Params[[[true, true], [false, false]], "Array"] - '@Params[[{"test":1}, {"test":1}], "AssociativeArray"] - function assertArrayContainsOnlyValuesOfType_Pass(values, typeName) as void - - assertResult = m.assertArrayContainsOnlyValuesOfType(values, typeName) - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertTrue(assertResult) - m.assertFalse(isFail) - - end function - - '@Test fail - '@Params[["one", 2, "three"], "String"] - '@Params[[1, "two", 3], "Integer"] - '@Params[[true, "true", false], "Boolean"] - '@Params[[[true, true], false, false], "Array"] - '@Params[[{"test":1}, "notAA"], "AssociativeArray"] - '@Params[["one", "two", "three"], "UnknownType"] - '@Params[["one", "two", "three"], "Integer"] - '@Params[[1, 2, 3], "String"] - '@Params[[true, true, false], "String"] - '@Params[[[true, true], [false, false]], "AssociativeArray"] - '@Params[[{"test":1}, {"test":1}], "Array"] - function assertArrayContainsOnlyValuesOfType_Fail(values, typeName) as void - - assertResult = m.assertArrayContainsOnlyValuesOfType(values, typeName) - isFail = m.currentResult.isFail - - isFail = m.currentResult.isFail - m.currentResult.Reset() - - m.assertFalse(assertResult) - m.assertTrue(isFail) - - - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests white spaces work with annotations - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - 'some comments to - 'demonstrate - '@Test comments between tests - 'that we can have comments - 'between functions and tags - function whiteSpacing() as void - m.assertTrue(true) - end function - - 'some comments to - 'demonstrate - '@Test comments between tests with params - '@Params[1] - - '@Params[2] - 'that we can have comments - '@Params[3] - 'between functions and tags - '@Params[4] - - function whiteSpacing_params(value) as void - m.assertTrue(true) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests AssertNotEmpty - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test pass - '@Params[["one", "two", "three"]] - '@Params[[1, 2, 3]] - '@Params[[true]] - '@Params[[[true, true], [false, false]]] - '@Params[[{"test":1}]] - '@Params["not empty"] - '@Params[[invalid]] - function assertNotEmpty_Pass(values) as void - - assertResult = m.assertNotEmpty(values) - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertTrue(assertResult) - m.assertFalse(isFail) - - end function - - '@Test fail - '@Params[invalid] - '@Params[[]] - '@Params[{}] - '@Params[1] - '@Params[""] - function assertNotEmpty_Fail(values) as void - - assertResult = m.assertNotEmpty(values) - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertFalse(assertResult) - m.assertTrue(isFail) - - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests AssertEmpty - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test pass - '@Params[[]] - '@Params[{}] - '@Params[""] - function assertEmpty_Pass(values) as void - - assertResult = m.assertEmpty(values) - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertTrue(assertResult) - m.assertFalse(isFail) - - end function - - '@Test fail - '@Params[1] - '@Params[invalid] - '@Params[["one", "two", "three"]] - '@Params[[1, 2, 3]] - '@Params[[true]] - '@Params[[[true, true], [false, false]]] - '@Params[[{"test":1}]] - '@Params["not empty"] - '@Params[[invalid]] - function assertEmpty_Fail(values) as void - - assertResult = m.assertEmpty(values) - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertFalse(assertResult) - m.assertTrue(isFail) - - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests expect - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test multi return values - function expect_multiValues() - obj = {} - m.expect(obj, "mockMethod", 5, invalid, { "multiResult": ["one", 2, invalid, "last"] }, true) - - result = obj.mockMethod() - m.assertEqual(result, "one") - - result = obj.mockMethod() - m.assertEqual(result, 2) - - result = obj.mockMethod() - m.assertEqual(result, invalid) - - result = obj.mockMethod() - m.assertEqual(result, "last") - - result = obj.mockMethod() - m.assertEqual(result, "last") - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertFalse(isFail) - - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests expect with overloaded expectOnce - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test simple test - function expect_multiExpect_success() - obj = {} - arg1 = "arg1" - arg2 = "arg2" - arg3 = "arg3" - result1 = 1 - result2 = 2 - result3 = 3 - - m.expectOnce(obj, "mockMethod", [arg1], result1, true) - m.expectOnce(obj, "mockMethod", [arg2], result2, true) - m.expectOnce(obj, "mockMethod", [arg3], result3, true) - - result = obj.mockMethod(arg1) - m.assertEqual(result, result1) - - result = obj.mockMethod(arg2) - m.assertEqual(result, result2) - - result = obj.mockMethod(arg3) - m.assertEqual(result, result3) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertFalse(isFail) - end function - - - '@Test can set up multi expects on same method - one invocation with any args - function expect_multiExpect_success_oneCallsArgsNotTracked() - obj = {} - arg1 = "arg1" - arg2 = "arg2" - arg3 = "arg3" - result1 = 1 - result2 = 2 - result3 = 3 - - m.expectOnce(obj, "mockMethod", [arg1], result1, true) - m.expectOnce(obj, "mockMethod", invalid, result2, true) - m.expectOnce(obj, "mockMethod", [arg3], result3, true) - - result = obj.mockMethod(arg1) - m.assertEqual(result, result1) - - result = obj.mockMethod("do not care about args", "used in invocation", 2) - m.assertEqual(result, result2) - - result = obj.mockMethod(arg3) - m.assertEqual(result, result3) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertFalse(isFail) - - end function - - '@Test can set up multi expects on same method - multi params - function expect_multiExpect_multi_args_success() - obj = {} - arg1 = "arg1" - arg2 = "arg2" - arg3 = "arg3" - result1 = 1 - result2 = 2 - result3 = 3 - - m.expectOnce(obj, "mockMethod", [arg1, arg2, arg3], result1, true) - m.expectOnce(obj, "mockMethod", [arg2, arg3, arg1], result2, true) - m.expectOnce(obj, "mockMethod", [arg3, arg2, arg1], result3, true) - - result = obj.mockMethod(arg1, arg2, arg3) - m.assertEqual(result, result1) - - result = obj.mockMethod(arg2, arg3, arg1) - m.assertEqual(result, result2) - - result = obj.mockMethod(arg3, arg2, arg1) - m.assertEqual(result, result3) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertFalse(isFail) - - end function - - '@Test multi test, multi params with other expects - function expect_multiExpect_multi_args_others_success() - obj = {} - arg1 = "arg1" - arg2 = "arg2" - arg3 = "arg3" - result1 = 1 - result2 = 2 - result3 = 3 - - m.expectOnce(obj, "anotherMockMethod", invalid, "another", true) - m.expectOnce(obj, "anotherMockMethod2", [1, 2, 3], "another2", true) - m.expectOnce(obj, "mockMethod", [arg1, arg2, arg3], result1, true) - m.expectOnce(obj, "mockMethod", [arg2, arg3, arg1], result2, true) - m.expectOnce(obj, "mockMethod", [arg3, arg2, arg1], result3, true) - - result = obj.anotherMockMethod() - m.assertEqual(result, "another") - - result = obj.anotherMockMethod2(1, 2, 3) - m.assertEqual(result, "another2") - - result = obj.mockMethod(arg1, arg2, arg3) - m.assertEqual(result, result) - - result = obj.mockMethod(arg2, arg3, arg1) - m.assertEqual(result, result2) - - result = obj.mockMethod(arg3, arg2, arg1) - m.assertEqual(result, result3) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertFalse(isFail) - - end function - - '@Test multi test, multi params with other expects - fail others - function expect_multiExpect_multi_args_others_fail() - obj = {} - arg1 = "arg1" - arg2 = "arg2" - arg3 = "arg3" - result1 = 1 - result2 = 2 - result3 = 3 - - m.expectOnce(obj, "anotherMockMethod", ["not passed"], "another", true) - m.expectOnce(obj, "anotherMockMethod2", [1, 2, 3], "another2", true) - m.expectOnce(obj, "mockMethod", [arg1, arg2, arg3], result1, true) - m.expectOnce(obj, "mockMethod", [arg2, arg3, arg1], result2, true) - m.expectOnce(obj, "mockMethod", [arg3, arg2, arg1], result3, true) - - result = obj.anotherMockMethod() - m.assertEqual(result, "another") - - result = obj.anotherMockMethod2(1, 2, 3) - m.assertEqual(result, "another2") - - result = obj.mockMethod(arg1, arg2, arg3) - m.assertEqual(result, result) - - result = obj.mockMethod(arg2, arg3, arg1) - m.assertEqual(result, result2) - - result = obj.mockMethod(arg3, arg2, arg1) - m.assertEqual(result, result3) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertTrue(isFail) - - end function - - '@Test can set up multi expects on same method - '@Params["arg1_", "arg2", "arg3"] - '@Params["arg1", "arg2", "arg3_"] - '@Params["arg1", "arg2_", "arg3"] - '@Params["arg1", "arg2_", "arg3"] - '@Params["arg1_", "arg2_", "arg3"] - '@Params["arg1_", invalid, "arg3"] - function expect_multiExpect_fail(call1, call2, call3) - obj = {} - arg1 = "arg1" - arg2 = "arg2" - arg3 = "arg3" - result1 = 1 - result2 = 2 - result3 = 3 - - m.expectOnce(obj, "mockMethod", [arg1], result1, true) - m.expectOnce(obj, "mockMethod", [arg2], result2, true) - m.expectOnce(obj, "mockMethod", [arg3], result3, true) - - result = obj.mockMethod(call1) - m.assertEqual(result, result1) - - result = obj.mockMethod(call2) - m.assertEqual(result, result2) - - result = obj.mockMethod(call2) - m.assertEqual(result, result3) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertTrue(isFail) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests overloaded expectOnce on different objects - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test success - function expect_multiExpect_differentOnj_success() - obj = {} - obj2 = {} - arg1 = "arg1" - arg2 = "arg2" - arg3 = "arg3" - result1 = 1 - result2 = 2 - result3 = 3 - - m.expectOnce(obj, "mockMethod", [arg1], result1, true) - m.expectOnce(obj, "mockMethod", [arg2], result2, true) - m.expectOnce(obj2, "mockMethod", [arg3], result3, true) - - result = obj.mockMethod(arg1) - m.assertEqual(result, result1) - - result = obj.mockMethod(arg2) - m.assertEqual(result, result2) - - result = obj2.mockMethod(arg3) - m.assertEqual(result, result3) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertFalse(isFail) - - end function - - '@Test fail to match - function expect_multiExpect_differentOnj_fail() - obj = {} - obj2 = {} - arg1 = "arg1" - arg2 = "arg2" - arg3 = "arg3" - result1 = 1 - result2 = 2 - result3 = 3 - - m.expectOnce(obj, "mockMethod", [arg1], result1, true) - m.expectOnce(obj, "mockMethod", [arg2], result2, true) - m.expectOnce(obj2, "mockMethod", [arg3], result3, true) - - result = obj.mockMethod(arg1) - m.assertEqual(result, result1) - - result = obj.mockMethod(arg2) - m.assertEqual(result, result2) - - result = obj2.mockMethod(arg3) - m.assertEqual(result, result3) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertFalse(isFail) - - end function - - 'ASSERTIONS TO WRITE TESTS FOR! - - 'This is coming soon! - - ' AssertEqual - ' AssertLike - ' AssertNotEqual - ' AssertInvalid - ' AssertNotInvalid - ' AssertAAHasKey - ' AssertAANotHasKey - ' AssertAAHasKeys - ' AssertAANotHasKeys - ' AssertArrayNotContains - ' AssertArrayContainsSubset - ' AssertArrayNotContainsSubsetet - ' AssertArrayCount - ' AssertArrayNotCount - ' AssertArrayContainsOnly - ' AssertType - ' AssertSubType - ' - ' 'Node extensions - ' AssertNodeCount - ' AssertNodeNotCount - ' AssertNodeEmpty - ' AssertNodeNotEmpty - ' AssertNodeContains - ' AssertNodeNotContains - ' AssertNodeContainsFields - ' AssertNodeNotContainsFields - - ' AssertArray - ' AssertAAContainsSubset - ' - ' 'Mocking and stubbing - ' AssertMocks - ' MockFail -end namespace \ No newline at end of file diff --git a/tests/src/tests/BasicTests.bs b/tests/src/tests/BasicTests.bs deleted file mode 100644 index 7b908204..00000000 --- a/tests/src/tests/BasicTests.bs +++ /dev/null @@ -1,81 +0,0 @@ -'@TestSuite [BT] Basic tests -namespace Tests.BasicTests - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests the node context is available for a Node scope function - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test - function NodeScope() as void - m.assertNotInvalid(m.node) - Tests.BasicTests.doSomethingInNodeScope(true) - m.assertInvalid(m._isNodeScopeVarSet) - m.assertTrue(m.node._isNodeScopeVarSet) - end function - - function doSomethingInNodeScope(value) - m._isNodeScopeVarSet = value - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests aa's with a mock will not crash the box! - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test - function EqualsFixForStubbedAAs() as void - aa = { "test": "value" } - m.expectOnce(aa, "getStubbedObject", [aa]) - - aa.getStubbedObject(aa) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests aa's that get printed as failures don't crash box - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test - function PrintResultsFixForStubbedAAs() as void - aa = { "test": "value" } - bb = { "other": "value" } - m.expectOnce(bb, "getStubbedObject", [aa]) - m.assertEqual(aa, bb) - 'not crashing on printing the wrong output is a pass - m.assertMocks() - m.currentResult.Reset() - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It url in params - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test simple - '@Params["http://101.rooibos.com"] - function urlParams(url) as void - m.assertEqual(url, "http://101.rooibos.com") - end function - - '@Test on objects - '@Params[{"url":"http://101.rooibos.com", "othervalue":2}] - '@Params[{url:"http://101.rooibos.com", "othervalue":2}] - '@Params[{url:"http://101.rooibos.com", othervalue:2}] - function urlParams_objects(aa) as void - m.assertEqual(aa.url, "http://101.rooibos.com") - m.assertEqual(aa.othervalue, 2) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests async tests - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test times out - function async_timeout() - item = { "id": "item" } - - m.assertAsyncField(item, "id") - isFail = m.currentResult.isFail - m.currentResult.Reset() - m.assertTrue(isFail) - - end function - -end namespace \ No newline at end of file diff --git a/tests/src/tests/CommonTests.bs b/tests/src/tests/CommonTests.bs deleted file mode 100644 index 864261cf..00000000 --- a/tests/src/tests/CommonTests.bs +++ /dev/null @@ -1,28 +0,0 @@ -'@TestSuite RCMT Common tests - -namespace Common - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests EqArray - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test - '@Params[invalid, [], false] - '@Params[[], invalid, false] - '@Params[invalid, invalid, false] - '@Params[["one", "three"], [], false] - '@Params[[], ["one", "three"], false] - '@Params[[], [], true] - '@Params[["one", "two", "three"], ["one", "three"], false] - '@Params[["one", "two", "three"], ["one", "two", "three"], true] - '@Params[[1, 2, 3], ["one", "two", "three"], false] - '@Params[[1, 2, 3], [1, 2, 3], true] - '@Params[[1, invalid, "3"], [1, invalid, "3"], true] - '@Params[[3, 2, 1], [1, 2, 3], false] - function eqArray_Pass(values, values2, expected) as void - - result = Common.eqArray(values, values2) - m.assertEqual(result, expected) - - end function - -end namespace \ No newline at end of file diff --git a/tests/src/tests/ExpectTests.bs b/tests/src/tests/ExpectTests.bs deleted file mode 100644 index 5cf797d9..00000000 --- a/tests/src/tests/ExpectTests.bs +++ /dev/null @@ -1,55 +0,0 @@ -'@TestSuite ET ExpectTests - -namespace Tests.ExpectTests - -'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -'@It tests bug with expectOnce not matching values -'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -'@Test reported case -'@Params[[52], true] -'@Params[invalid, false] -'@Params[[invalid], true] -'@Params[["42"], true] -'@Params[[42], false] -function expectOnce_valuesBug_reported(expectedValue, expectMockFail) as void - obj = { - foo: function(arg0) : return arg0 : end function - } - - m.ExpectOnce(obj, "foo", expectedValue) - obj.foo(42) - m.isAutoAssertingMocks = false - m.assertMocks() - - isFail = m.currentResult.isFail - m.currentResult.Reset() - m.CleanMocks() - m.assertEqual(isFail, expectMockFail) -end function - - -'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -'@It tests mock count limit -'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -'@Test mock count limit at least 25 -function expect_mockCountLimitToBeAtLeast25() as void - - interface = {} - - mockCountLimit = 25 - for i = 1 to mockCountLimit - keyName = StrI(i).trim() - interface[keyName] = function(arg0) : return arg0 : end function - - expectedArg = "a" - expectedReturnValue = "b" - m.ExpectOnce(interface, keyName, [expectedArg], [expectedReturnValue]) - - interface[keyName](expectedArg) - end for - -end function - -end namespace \ No newline at end of file diff --git a/tests/src/tests/MatcherTests.bs b/tests/src/tests/MatcherTests.bs deleted file mode 100644 index 5abc50fc..00000000 --- a/tests/src/tests/MatcherTests.bs +++ /dev/null @@ -1,211 +0,0 @@ -'@TestSuite [MT] Matcher Tests -namespace Tests.MatcherTests - - '@BeforeEach - function beforeEach() - 'make a mock class - m.myClass = {} - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests a custom matcher - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test couple of custom matchers - '@Params[true, false, false] - '@Params[false, true, true] - '@Params[false, false, true] - '@Params[true, true, true] - function matcher_boolean(v1, v2, expectedFail) - returnValue = "notBroken" - m.expectOnce(m.myClass, "doWork", [{ "matcher": match_true }, { "matcher": match_false }], returnValue) - - m.assertEqual(m.myClass.doWork(v1, v2), returnValue) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertEqual(isFail, expectedFail) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests a custom inline matcher - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test - '@Params[true, false, false] - '@Params[false, true, true] - '@Params[false, false, true] - '@Params[true, true, true] - function inline_matcher_boolean(v1, v2, expectedFail) - returnValue = "notBroken" - m.expectOnce(m.myClass, "doWork", [{ "matcher": function(value) - return value = true - end function }, { "matcher": function(value) - return value = false - end function }], returnValue) - - m.assertEqual(m.myClass.doWork(v1, v2), returnValue) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertEqual(isFail, expectedFail) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '++ built in matchers - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test anyBoolMatcher - '@Params[invalid, true] - '@Params["false", true] - '@Params["true", true] - '@Params[23, true] - '@Params[{}, true] - '@Params[[], true] - '@Params[false, false] - '@Params[true, false] - function matcher_built_in_anyBoolean(v1, expectedFail) - returnValue = "notBroken" - m.expectOnce(m.myClass, "doWork", [m.anyBoolMatcher], returnValue) - - m.assertEqual(m.myClass.doWork(v1), returnValue) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertEqual(isFail, expectedFail) - end function - - '@Test anyStringMatcher - '@Params[invalid, true] - '@Params["false", false] - '@Params["true", false] - '@Params[23, true] - '@Params[{}, true] - '@Params[[], true] - '@Params[false, true] - '@Params[true, true] - function matcher_built_in_anyString(v1, expectedFail) - returnValue = "notBroken" - m.expectOnce(m.myClass, "doWork", [m.anyStringMatcher], returnValue) - - m.assertEqual(m.myClass.doWork(v1), returnValue) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertEqual(isFail, expectedFail) - end function - - '@Test anyNumberMatcher - '@Params[invalid, true] - '@Params["false", true] - '@Params["true", true] - '@Params[23, false] - '@Params[9, false] - '@Params[0, false] - '@Params[0.2, false] - '@Params[{}, true] - '@Params[[], true] - '@Params[false, true] - '@Params[true, true] - function matcher_built_in_anyNumber(v1, expectedFail) - returnValue = "notBroken" - m.expectOnce(m.myClass, "doWork", [m.anyNumberMatcher], returnValue) - - m.assertEqual(m.myClass.doWork(v1), returnValue) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertEqual(isFail, expectedFail) - end function - - '@Test anyAAMatcher - '@Params[invalid, true] - '@Params["false", true] - '@Params["true", true] - '@Params[23, true] - '@Params[{}, false] - '@Params[[], true] - '@Params[false, true] - '@Params[true, true] - function matcher_built_in_anyAA(v1, expectedFail) - returnValue = "notBroken" - m.expectOnce(m.myClass, "doWork", [m.anyAAMatcher], returnValue) - - m.assertEqual(m.myClass.doWork(v1), returnValue) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertEqual(isFail, expectedFail) - end function - - '@Test anyArrayMatcher - '@Params[invalid, true] - '@Params["false", true] - '@Params["true", true] - '@Params[23, true] - '@Params[{}, true] - '@Params[[], false] - '@Params[false, true] - '@Params[true, true] - function matcher_built_in_anyArray(v1, expectedFail) - returnValue = "notBroken" - m.expectOnce(m.myClass, "doWork", [m.anyArrayMatcher], returnValue) - - m.assertEqual(m.myClass.doWork(v1), returnValue) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertEqual(isFail, expectedFail) - end function - - '@Test anyNodeMatcher - '@Params[invalid, true] - '@Params["false", true] - '@Params["true", true] - '@Params[23, true] - '@Params[{}, true] - '@Params["#RBSNode", false] - '@Params[[], true] - '@Params[false, true] - '@Params[true, true] - function matcher_built_in_anyNode(v1, expectedFail) - returnValue = "notBroken" - m.expectOnce(m.myClass, "doWork", [m.anyNodeMatcher], returnValue) - - m.assertEqual(m.myClass.doWork(v1), returnValue) - - m.assertMocks() - isFail = m.currentResult.isFail - - m.currentResult.Reset() - m.assertEqual(isFail, expectedFail) - end function - - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '++ matchers - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - function match_true(value) - return value = true - end function - - function match_false(value) - return value = false - end function - -end namespace \ No newline at end of file diff --git a/tests/src/tests/NodeExampleTests.bs b/tests/src/tests/NodeExampleTests.bs deleted file mode 100644 index 820649b5..00000000 --- a/tests/src/tests/NodeExampleTests.bs +++ /dev/null @@ -1,39 +0,0 @@ -'@SGNode NodeExampleTests -'@TestSuite [NET] Node Example Tests -namespace Tests.NodeExampleTests - - '@Setup - function setup() as void - m.setupThing = "something created during setup" - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests methods present on the node - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@BeforeEach - function beforeEach() as void - m.beforeEachThing = "something created beforeEach" - end function - - '@Test HelloFromNode - function helloFromNode_simple() as void - 'bs:disable-next-line - text = HelloFromNode("georgejecook", 12) - m.AssertEqual(text, "HELLO georgejecook" + " age:" + stri(12)) - end function - - '@Test HelloFromNode with params - '@Params["jon", 40] - '@Params["ringo", 23] - '@Params["ringo", 50] - '@Params["ringo", 24] - '@Params["george", 40] - '@Params["paul", 50] - function helloFromNode_params(name, age) as void - 'bs:disable-next-line - text = HelloFromNode(name, age) - m.AssertEqual(text, "HELLO " + name + " age:" + stri(age)) - end function - -end namespace diff --git a/tests/src/tests/ParamsTests.bs b/tests/src/tests/ParamsTests.bs deleted file mode 100644 index 6d18225b..00000000 --- a/tests/src/tests/ParamsTests.bs +++ /dev/null @@ -1,35 +0,0 @@ -'@TestSuite PT ParamsTests -namespace Tests.ParamsTest - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests that nodes are created with RBSNode - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test - '@Params["#RBSNode", "ContentNode"] - '@Params["#RBSNode|Group", "Group"] - '@Params["#RBSNode|Label", "Label"] - function nodeDirective(node, expectedNodeType) as void - m.assertSubType(node, expectedNodeType) - end function - - '@Test node parsed as other arg index - '@Params[1, 2, 3, "#RBSNode", "ContentNode"] - '@Params[1, 2, 3, "#RBSNode|Group", "Group"] - '@Params[1, 2, 3, "#RBSNode|Label", "Label"] - function nodeDirective_otherArgs(arg1, arg2, arg3, node, expectedNodeType) as void - m.assertSubType(node, expectedNodeType) - m.assertEqual(arg1, 1) - m.assertEqual(arg2, 2) - m.assertEqual(arg3, 3) - end function - - '@Test does not affect regular params - '@Params["#someValue", "#someValue"] - '@Params[22, 22] - '@Params[[1,2,3], [1,2,3]] - function nodeDirective_noSideEffect(arg1, expectedValue) as void - m.assertEqual(arg1, expectedValue) - end function - -end namespace \ No newline at end of file diff --git a/tests/src/tests/VersionTests.bs b/tests/src/tests/VersionTests.bs deleted file mode 100644 index 099392e6..00000000 --- a/tests/src/tests/VersionTests.bs +++ /dev/null @@ -1,26 +0,0 @@ -'@TestSuite [VT] Version tests - -namespace Tests.VersionTests - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests versionCompare - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test - '@Params["0.1", "0.1", 0] - '@Params["1.0", "1.0", 0] - '@Params["1.0.0", "1.0.0", 0] - '@Params["1.0.1", "1.0.1", 0] - '@Params["0.1", "0.2", -1] - '@Params["1.0", "2.0", -1] - '@Params["1.0.0", "2.0.0", -1] - '@Params["2.0.0", "2.0.1", -1] - '@Params["0.2", "0.1", 1] - '@Params["2.0", "1.0", 1] - '@Params["2.0.0", "1.0.0", 1] - '@Params["2.0.1", "2.0.0", 1] - function versionCompare(v1, v2, expected) as void - m.assertEqual(versionCompare(v1, v2), expected) - end function - -end namespace diff --git a/tests/src/tests/issue_13_afterEach_not_running.bs b/tests/src/tests/issue_13_afterEach_not_running.bs deleted file mode 100644 index 92be8699..00000000 --- a/tests/src/tests/issue_13_afterEach_not_running.bs +++ /dev/null @@ -1,51 +0,0 @@ -'@Ignore - only unignore to test compiler works -'@TestSuite [DGNT] Duplicate Group Name Tests - -namespace Tests.AfterEachNotRunning - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It group1 - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test simple - function group1_test() - m.assertTrue(true) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It group2 - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test simple - function group2_test() - m.assertTrue(true) - end function - - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It group2 - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test simple - function group2_dupe_test() - m.assertTrue(true) - end function - - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It group3 - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test simple - function group3_test() - m.assertTrue(true) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It group1 - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test simple - function group1_dupe_test() - m.assertTrue(true) - end function -end namespace \ No newline at end of file diff --git a/tests/src/tests/issue_15_tests_only_on_groups.bs b/tests/src/tests/issue_15_tests_only_on_groups.bs deleted file mode 100644 index 1375f8ac..00000000 --- a/tests/src/tests/issue_15_tests_only_on_groups.bs +++ /dev/null @@ -1,31 +0,0 @@ -'ADD '@Only ON NEXT LINE TO TEST -'@TestSuite [RBSA] Rooibos before after tests -namespace Tests.OnlyOnGroups - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests one - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test it one - function it_test_one() as void - m.assertTrue(true) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests two - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test it two - function it_test_two() as void - m.assertTrue(true) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 'ADD '@Only ON NEXT LINE TO TEST - '@It tests three - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test it three - function it_test_three() as void - m.assertTrue(true) - end function -end namespace \ No newline at end of file diff --git a/tests/src/tests/issue_5_duplicateGroupNames.bs b/tests/src/tests/issue_5_duplicateGroupNames.bs deleted file mode 100644 index ebed3953..00000000 --- a/tests/src/tests/issue_5_duplicateGroupNames.bs +++ /dev/null @@ -1,32 +0,0 @@ -'@Ignore - only unignore to test compiler works - remove REMOVE_THIS to test -'@TestSuite [RBSA] REMOVE_THIS Rooibos before after tests -namespace Tests.DuplicateGroupNames - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests before each and after each are running - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@BeforeEach - function beforeEach() as void - ? "!!! Before" - end function - - - '@AfterEach - function afterEach() as void - ? "!!! After" - end function - - '@Test before after - function before_after() as void - - assertResult = m.Fail("reason") - - isFail = m.currentResult.isFail - m.currentResult.Reset() - - m.assertFalse(assertResult) - m.assertTrue(isFail) - end function - -end namespace \ No newline at end of file diff --git a/tests/src/tests/testConfig.json b/tests/src/tests/testConfig.json deleted file mode 100644 index 8380fe04..00000000 --- a/tests/src/tests/testConfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "logLevel": 1, - "failFast": false, - "showOnlyFailures": true -} diff --git a/tests/src/tests/testUtils.bs b/tests/src/tests/testUtils.bs deleted file mode 100644 index 4cf3d227..00000000 --- a/tests/src/tests/testUtils.bs +++ /dev/null @@ -1,8 +0,0 @@ - -sub AddTestUtils(test) - 'add your own test utils you want access to when testing here - - 'e.g. - 'test.testUtils = TestUtils() - 'test.r = rodash() -end sub \ No newline at end of file diff --git a/tests/src/tests/verifyBeforeEachAfterEach.bs b/tests/src/tests/verifyBeforeEachAfterEach.bs deleted file mode 100644 index a89004cb..00000000 --- a/tests/src/tests/verifyBeforeEachAfterEach.bs +++ /dev/null @@ -1,102 +0,0 @@ -'@TestSuite [BEAER] BeforeEach and AfterEach Running -namespace Tests.VeritfyBeforeEachAfterEach - - '@Setup - function Setup() as void - ? "!!! Setup" - end function - - - '@TearDown - function TearDown() as void - ? "!!! TearDown" - end function - - '@BeforeEach - function BeforeEach() as void - ? "!!! Before" - end function - - - '@AfterEach - function AfterEach() as void - ? "!!! After" - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests group 1 - should have global before/after - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test 1 - function group1_1() as void - m.assertTrue(true) - end function - - '@Test 2 - function group1_2() as void - m.assertTrue(true) - end function - - '@Test 3 - '@Params["a"] - '@Params["b"] - '@Params["c"] - function group1_3(values) as void - m.assertTrue(true) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests group 2 - should have group before after - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@BeforeEach - function group2_BeforeEach() as void - ? "!!! Before GROUP 2" - end function - - - '@AfterEach - function group2_AfterEach() as void - ? "!!! After GROUP 2" - end function - - '@Test 1 - function group2_1() as void - m.assertTrue(true) - end function - - '@Test 2 - function group2_2() as void - m.assertTrue(true) - end function - - '@Test 3 - '@Params["a"] - '@Params["b"] - '@Params["c"] - function group2_3(values) as void - m.assertTrue(true) - end function - - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - '@It tests group 3 - should have global before/after - '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '@Test 1 - function group3_1() as void - m.assertTrue(true) - end function - - '@Test 2 - function group3_2() as void - m.assertTrue(true) - end function - - '@Test 3 - '@Params["a"] - '@Params["b"] - '@Params["c"] - function group3_3(values) as void - m.assertTrue(true) - end function -end namespace