Skip to content

Commit

Permalink
2.1.4 adds paramter directive to allow creation of nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
George Cook committed Apr 26, 2019
1 parent b22363d commit 189b1be
Show file tree
Hide file tree
Showing 20 changed files with 128 additions and 18 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.2
2.1.4
16 changes: 14 additions & 2 deletions dist/rooibosDist.brs
Original file line number Diff line number Diff line change
@@ -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
' */
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion docs/Rooibos.brs.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ <h1 class="page-title">Rooibos.brs</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Apr 25 2019 18:06:17 GMT-0500 (-05) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Apr 26 2019 13:36:16 GMT-0500 (-05) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/Rooibos_BaseTestSuite.brs.html
Original file line number Diff line number Diff line change
Expand Up @@ -2003,7 +2003,7 @@ <h1 class="page-title">Rooibos_BaseTestSuite.brs</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Apr 25 2019 18:06:17 GMT-0500 (-05) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Apr 26 2019 13:36:16 GMT-0500 (-05) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/Rooibos_CommonUtils.brs.html
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ <h1 class="page-title">Rooibos_CommonUtils.brs</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Apr 25 2019 18:06:17 GMT-0500 (-05) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Apr 26 2019 13:36:16 GMT-0500 (-05) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/Rooibos_ItemGenerator.brs.html
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ <h1 class="page-title">Rooibos_ItemGenerator.brs</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Apr 25 2019 18:06:17 GMT-0500 (-05) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Apr 26 2019 13:36:16 GMT-0500 (-05) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
13 changes: 12 additions & 1 deletion docs/Rooibos_TestRunner.brs.html
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,17 @@ <h1 class="page-title">Rooibos_TestRunner.brs</h1>
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])
Expand Down Expand Up @@ -415,7 +426,7 @@ <h1 class="page-title">Rooibos_TestRunner.brs</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Apr 25 2019 18:06:17 GMT-0500 (-05) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Apr 26 2019 13:36:16 GMT-0500 (-05) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Apr 25 2019 18:06:17 GMT-0500 (-05) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Apr 26 2019 13:36:16 GMT-0500 (-05) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
16 changes: 16 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/module-BaseTestSuite.html
Original file line number Diff line number Diff line change
Expand Up @@ -12420,7 +12420,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Apr 25 2019 18:06:17 GMT-0500 (-05) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Apr 26 2019 13:36:16 GMT-0500 (-05) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/module-CommonUtils.html
Original file line number Diff line number Diff line change
Expand Up @@ -5062,7 +5062,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Apr 25 2019 18:06:17 GMT-0500 (-05) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Apr 26 2019 13:36:16 GMT-0500 (-05) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/module-ItemGenerator.html
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Apr 25 2019 18:06:17 GMT-0500 (-05) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Apr 26 2019 13:36:16 GMT-0500 (-05) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/module-TestRunner.html
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ <h4 class="name" id="Run"><span class="type-signature"></span>Run<span class="si
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Apr 25 2019 18:06:17 GMT-0500 (-05) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Apr 26 2019 13:36:16 GMT-0500 (-05) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/module-rooibosh.html
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ <h5>Parameters:</h5>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Thu Apr 25 2019 18:06:17 GMT-0500 (-05) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Apr 26 2019 13:36:16 GMT-0500 (-05) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
1 change: 1 addition & 0 deletions frameworkTests/source/tests/ExpectTests.brs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'@TestSuite ET ExpectTests

'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'@It tests bug with expectOnce not matching values
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down
32 changes: 32 additions & 0 deletions frameworkTests/source/tests/ParamsTests.brs
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
16 changes: 14 additions & 2 deletions samples/example/source/tests/rooibos/rooibosDist.brs
Original file line number Diff line number Diff line change
@@ -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
' */
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 13 additions & 1 deletion src/Rooibos_TestRunner.brs
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit 189b1be

Please sign in to comment.