From 189b1be7425455b6d55afe09e81dd267102f0f12 Mon Sep 17 00:00:00 2001 From: George Cook Date: Fri, 26 Apr 2019 13:58:33 -0500 Subject: [PATCH] 2.1.4 adds paramter directive to allow creation of nodes --- CHANGELOG.md | 14 ++++++++ VERSION | 2 +- dist/rooibosDist.brs | 16 ++++++++-- docs/Rooibos.brs.html | 2 +- docs/Rooibos_BaseTestSuite.brs.html | 2 +- docs/Rooibos_CommonUtils.brs.html | 2 +- docs/Rooibos_ItemGenerator.brs.html | 2 +- docs/Rooibos_TestRunner.brs.html | 13 +++++++- docs/index.html | 2 +- docs/index.md | 16 ++++++++++ docs/module-BaseTestSuite.html | 2 +- docs/module-CommonUtils.html | 2 +- docs/module-ItemGenerator.html | 2 +- docs/module-TestRunner.html | 2 +- docs/module-rooibosh.html | 2 +- frameworkTests/source/tests/ExpectTests.brs | 1 + frameworkTests/source/tests/ParamsTests.brs | 32 +++++++++++++++++++ package.json | 2 +- .../source/tests/rooibos/rooibosDist.brs | 16 ++++++++-- src/Rooibos_TestRunner.brs | 14 +++++++- 20 files changed, 128 insertions(+), 18 deletions(-) create mode 100644 frameworkTests/source/tests/ParamsTests.brs diff --git a/CHANGELOG.md b/CHANGELOG.md index 64f0b19b..1bd3499d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Rooibos CHANGELOG +## 2.1.4 + +### Added + + - adds new Parameter arg directive #RBSNode, to allow creation of nodes in the parameterized args + +### Changed + +### Deprecated + +### Removed + +### Fixed + ## 2.1.3 ### Added diff --git a/VERSION b/VERSION index eca07e4c..7d2ed7c7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.1.2 +2.1.4 diff --git a/dist/rooibosDist.brs b/dist/rooibosDist.brs index 1d8104b4..25173ce1 100644 --- a/dist/rooibosDist.brs +++ b/dist/rooibosDist.brs @@ -1,6 +1,6 @@ '/** ' * rooibos - simple, flexible, fun brightscript test framework for roku scenegraph apps -' * @version v2.0.0 +' * @version v2.1.4 ' * @link https://github.com/georgejecook/rooibos#readme ' * @license MIT ' */ @@ -2121,7 +2121,19 @@ sub RBS_RT_RunTestCases(metaTestSuite, itGroup, testSuite, totalStatObj, config, testStatObj.metaTestCase.testResult = testSuite.currentResult if (metaTestCase.isParamsValid) if (metaTestCase.isParamTest) - testCaseParams = metaTestCase.rawParams + testCaseParams = [] + for paramIndex = 0 to metaTestCase.rawParams.count() + paramValue = metaTestCase.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 + testCaseParams.push(paramValue) + end for if (metaTestCase.expectedNumberOfParams = 1) testSuite.testCase(testCaseParams[0]) else if (metaTestCase.expectedNumberOfParams = 2) diff --git a/docs/Rooibos.brs.html b/docs/Rooibos.brs.html index aa37c6a8..29d640f3 100644 --- a/docs/Rooibos.brs.html +++ b/docs/Rooibos.brs.html @@ -122,7 +122,7 @@

Rooibos.brs


diff --git a/docs/Rooibos_BaseTestSuite.brs.html b/docs/Rooibos_BaseTestSuite.brs.html index 58bd6f8f..973d5024 100644 --- a/docs/Rooibos_BaseTestSuite.brs.html +++ b/docs/Rooibos_BaseTestSuite.brs.html @@ -2003,7 +2003,7 @@

Rooibos_BaseTestSuite.brs


diff --git a/docs/Rooibos_CommonUtils.brs.html b/docs/Rooibos_CommonUtils.brs.html index 2f63f3d2..c161c2a9 100644 --- a/docs/Rooibos_CommonUtils.brs.html +++ b/docs/Rooibos_CommonUtils.brs.html @@ -598,7 +598,7 @@

Rooibos_CommonUtils.brs


diff --git a/docs/Rooibos_ItemGenerator.brs.html b/docs/Rooibos_ItemGenerator.brs.html index 24f2bff2..50ca83f6 100644 --- a/docs/Rooibos_ItemGenerator.brs.html +++ b/docs/Rooibos_ItemGenerator.brs.html @@ -273,7 +273,7 @@

Rooibos_ItemGenerator.brs


diff --git a/docs/Rooibos_TestRunner.brs.html b/docs/Rooibos_TestRunner.brs.html index e8e50633..a4ba26ac 100644 --- a/docs/Rooibos_TestRunner.brs.html +++ b/docs/Rooibos_TestRunner.brs.html @@ -302,6 +302,17 @@

Rooibos_TestRunner.brs

if (metaTestCase.isParamsValid) if (metaTestCase.isParamTest) testCaseParams = metaTestCase.rawParams + for paramIndex = 0 to testCaseParams.count() + paramValue = testCaseParams[paramIndex] + if type(paramValue) = "roString" and len(paramValue) > 8 and left(paramValue, 8 ) = "#RBSNode" + nodeType = "ContentNode" + paramDirectiveArgs = split(paramValue, "|") + if paramDirectiveArgs.count() > 0 + nodeType = paramDirectiveArgs[1] + end if + testCaseParams[paramIndex] = createObject("roSGnode", paramDirectiveArgs) + end if + end for 'up to 6 param args supported for now if (metaTestCase.expectedNumberOfParams = 1) testSuite.testCase(testCaseParams[0]) @@ -415,7 +426,7 @@

Rooibos_TestRunner.brs


diff --git a/docs/index.html b/docs/index.html index 6619cfc1..567d282c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -57,7 +57,7 @@
diff --git a/docs/index.md b/docs/index.md index f2243859..7d191de2 100644 --- a/docs/index.md +++ b/docs/index.md @@ -404,6 +404,22 @@ end function Paremeterized tests accept any valid json. However, the number of top level items in the params array must match the amount of arguments for your test method. If they don't the TestCase will fail. +#### Advanced paramter directives + +##### #RBSNode + +You can instruct rooibos to create nodes as your parameter arguments. To do so, use the special value `"#RBSNode"`, which will create a ContentNode for that value. You can also specify the nod type you wish to create. See the following example for guidance: + +``` +'@Test +'@Params["#RBSNode", "ContentNode"] +'@Params["#RBSNode|Group", "Group"] +'@Params["#RBSNode|Label", "Label"] +function PT_RBSNodeDirective(node, expectedNodeType) as void + m.assertSubType(node, expectedNodeType) +end function +``` + #### Parameterized test output The output from paremeterized tests shows the test name, and all of param configurations that were executed, making it easy to ascertain which param config results in a failure diff --git a/docs/module-BaseTestSuite.html b/docs/module-BaseTestSuite.html index ef125464..891541c5 100644 --- a/docs/module-BaseTestSuite.html +++ b/docs/module-BaseTestSuite.html @@ -12420,7 +12420,7 @@
Returns:

diff --git a/docs/module-CommonUtils.html b/docs/module-CommonUtils.html index e4d29448..54a0d71a 100644 --- a/docs/module-CommonUtils.html +++ b/docs/module-CommonUtils.html @@ -5062,7 +5062,7 @@
Returns:

diff --git a/docs/module-ItemGenerator.html b/docs/module-ItemGenerator.html index 7710435c..d7aa9841 100644 --- a/docs/module-ItemGenerator.html +++ b/docs/module-ItemGenerator.html @@ -1442,7 +1442,7 @@
Returns:

diff --git a/docs/module-TestRunner.html b/docs/module-TestRunner.html index 4a91dd02..14e91bd6 100644 --- a/docs/module-TestRunner.html +++ b/docs/module-TestRunner.html @@ -651,7 +651,7 @@

Run
- Generated by JSDoc 3.5.5 on Thu Apr 25 2019 18:06:17 GMT-0500 (-05) using the Minami theme. + Generated by JSDoc 3.5.5 on Fri Apr 26 2019 13:36:16 GMT-0500 (-05) using the Minami theme.
diff --git a/docs/module-rooibosh.html b/docs/module-rooibosh.html index 8320ae98..249a4200 100644 --- a/docs/module-rooibosh.html +++ b/docs/module-rooibosh.html @@ -273,7 +273,7 @@
Parameters:

- Generated by JSDoc 3.5.5 on Thu Apr 25 2019 18:06:17 GMT-0500 (-05) using the Minami theme. + Generated by JSDoc 3.5.5 on Fri Apr 26 2019 13:36:16 GMT-0500 (-05) using the Minami theme.
diff --git a/frameworkTests/source/tests/ExpectTests.brs b/frameworkTests/source/tests/ExpectTests.brs index 23196610..114ce322 100644 --- a/frameworkTests/source/tests/ExpectTests.brs +++ b/frameworkTests/source/tests/ExpectTests.brs @@ -1,4 +1,5 @@ '@TestSuite ET ExpectTests + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ '@It tests bug with expectOnce not matching values '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/frameworkTests/source/tests/ParamsTests.brs b/frameworkTests/source/tests/ParamsTests.brs new file mode 100644 index 00000000..a7ebed10 --- /dev/null +++ b/frameworkTests/source/tests/ParamsTests.brs @@ -0,0 +1,32 @@ +'@TestSuite PT ParamsTests + +'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +'@It tests that nodes are created with RBSNode +'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +'@Test +'@Params["#RBSNode", "ContentNode"] +'@Params["#RBSNode|Group", "Group"] +'@Params["#RBSNode|Label", "Label"] +function PT_RBSNodeDirective(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 PT_RBSNodeDirective_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 PT_RBSNodeDirective_noSideEffect(arg1, expectedValue) as void + m.assertEqual(arg1, expectedValue) +end function \ No newline at end of file diff --git a/package.json b/package.json index 8f7fbfb3..3a3dea81 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rooibos", - "version": "2.0.0", + "version": "2.1.4", "description": "simple, flexible, fun brightscript test framework for roku scenegraph apps", "main": "index.js", "directories": { diff --git a/samples/example/source/tests/rooibos/rooibosDist.brs b/samples/example/source/tests/rooibos/rooibosDist.brs index 1d8104b4..25173ce1 100644 --- a/samples/example/source/tests/rooibos/rooibosDist.brs +++ b/samples/example/source/tests/rooibos/rooibosDist.brs @@ -1,6 +1,6 @@ '/** ' * rooibos - simple, flexible, fun brightscript test framework for roku scenegraph apps -' * @version v2.0.0 +' * @version v2.1.4 ' * @link https://github.com/georgejecook/rooibos#readme ' * @license MIT ' */ @@ -2121,7 +2121,19 @@ sub RBS_RT_RunTestCases(metaTestSuite, itGroup, testSuite, totalStatObj, config, testStatObj.metaTestCase.testResult = testSuite.currentResult if (metaTestCase.isParamsValid) if (metaTestCase.isParamTest) - testCaseParams = metaTestCase.rawParams + testCaseParams = [] + for paramIndex = 0 to metaTestCase.rawParams.count() + paramValue = metaTestCase.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 + testCaseParams.push(paramValue) + end for if (metaTestCase.expectedNumberOfParams = 1) testSuite.testCase(testCaseParams[0]) else if (metaTestCase.expectedNumberOfParams = 2) diff --git a/src/Rooibos_TestRunner.brs b/src/Rooibos_TestRunner.brs index 3ae54ada..09846613 100644 --- a/src/Rooibos_TestRunner.brs +++ b/src/Rooibos_TestRunner.brs @@ -260,7 +260,19 @@ sub RBS_RT_RunTestCases(metaTestSuite, itGroup, testSuite, totalStatObj, config, if (metaTestCase.isParamsValid) if (metaTestCase.isParamTest) - testCaseParams = metaTestCase.rawParams + testCaseParams = [] + for paramIndex = 0 to metaTestCase.rawParams.count() + paramValue = metaTestCase.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 + testCaseParams.push(paramValue) + end for 'up to 6 param args supported for now if (metaTestCase.expectedNumberOfParams = 1) testSuite.testCase(testCaseParams[0])