Skip to content

Commit

Permalink
2.3.0 - adds ms time for each test in the test output
Browse files Browse the repository at this point in the history
  • Loading branch information
George Cook committed Apr 28, 2019
1 parent e9d7a40 commit f960e52
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 12 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.3.0

### Added

- prints ms duration of each test in the output

### Changed

### Deprecated

### Removed

### Fixed

## 2.2.0

### Added
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.0
2.3.0
12 changes: 9 additions & 3 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.2.0
' * @version v2.3.0
' * @link https://github.com/georgejecook/rooibos#readme
' * @license MIT
' */
Expand Down Expand Up @@ -1723,6 +1723,7 @@ function UnitTestCase(name as string, func as dynamic, funcName as string, isSol
this.rawParams = params
this.paramTestIndex = paramTestIndex
this.isParamTest = false
this.time = 0
if (params <> invalid)
this.name += stri(this.paramTestIndex)
end if
Expand Down Expand Up @@ -1811,7 +1812,7 @@ sub RBS_LOGGER_PrintTestStatistic(testCase as object)
insetText = ""
if (metaTestcase.isParamTest <> true)
messageLine = RBS_LOGGER_FillText(" " + testChar + " |--" + metaTestCase.Name + " : ", ".", 80)
? messageLine ; testCase.Result
? messageLine ; testCase.Result ; " (" + stri(metaTestCase.time).trim() +"ms)"
else if ( metaTestcase.paramTestIndex = 0)
name = metaTestCase.Name
if (len(name) > 1 and right(name, 1) = "0")
Expand All @@ -1822,7 +1823,7 @@ sub RBS_LOGGER_PrintTestStatistic(testCase as object)
if (metaTestcase.isParamTest = true)
insetText = " "
messageLine = RBS_LOGGER_FillText(" " + testChar + insetText + " |--" + formatJson(metaTestCase.rawParams) + " : ", ".", 80)
? messageLine ; testCase.Result
? messageLine ; testCase.Result ; " (" + stri(metaTestCase.time).trim() +"ms)"
end if
if LCase(testCase.Result) <> "success"
? " | "; insettext ;" |--Location: "; locationText
Expand Down Expand Up @@ -2118,6 +2119,7 @@ sub RBS_RT_RunTestCases(metaTestSuite, itGroup, testSuite, totalStatObj, config,
testSuite.beforeEach()
end if
testTimer = CreateObject("roTimespan")
testCaseTimer = CreateObject("roTimespan")
testStatObj = RBS_STATS_CreateTestStatistic(testCase.Name)
testSuite.testCase = testCase.Func
testStatObj.filePath = metaTestSuite.filePath
Expand All @@ -2139,6 +2141,7 @@ sub RBS_RT_RunTestCases(metaTestSuite, itGroup, testSuite, totalStatObj, config,
end if
testCaseParams.push(paramValue)
end for
testCaseTimer.mark()
if (metaTestCase.expectedNumberOfParams = 1)
testSuite.testCase(testCaseParams[0])
else if (metaTestCase.expectedNumberOfParams = 2)
Expand All @@ -2152,8 +2155,11 @@ sub RBS_RT_RunTestCases(metaTestSuite, itGroup, testSuite, totalStatObj, config,
else if (metaTestCase.expectedNumberOfParams = 6)
testSuite.testCase(testCaseParams[0], testCaseParams[1], testCaseParams[2], testCaseParams[3], testCaseParams[4], testCaseParams[5])
end if
metaTestCase.time = testCaseTimer.totalMilliseconds()
else
testCaseTimer.mark()
testSuite.testCase()
metaTestCase.time = testCaseTimer.totalMilliseconds()
end if
else
testSuite.Fail("Could not parse args for test ")
Expand Down
10 changes: 8 additions & 2 deletions outRun/.roku-deploy-staging/source/tests/rooibosDist.brs
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,7 @@ function UnitTestCase(name as string, func as dynamic, funcName as string, isSol
this.rawParams = params
this.paramTestIndex = paramTestIndex
this.isParamTest = false
this.time = 0
if (params <> invalid)
this.name += stri(this.paramTestIndex)
end if
Expand Down Expand Up @@ -1811,7 +1812,7 @@ sub RBS_LOGGER_PrintTestStatistic(testCase as object)
insetText = ""
if (metaTestcase.isParamTest <> true)
messageLine = RBS_LOGGER_FillText(" " + testChar + " |--" + metaTestCase.Name + " : ", ".", 80)
? messageLine ; testCase.Result
? messageLine ; testCase.Result ; " (" + stri(metaTestCase.time).trim() +"ms)"
else if ( metaTestcase.paramTestIndex = 0)
name = metaTestCase.Name
if (len(name) > 1 and right(name, 1) = "0")
Expand All @@ -1822,7 +1823,7 @@ sub RBS_LOGGER_PrintTestStatistic(testCase as object)
if (metaTestcase.isParamTest = true)
insetText = " "
messageLine = RBS_LOGGER_FillText(" " + testChar + insetText + " |--" + formatJson(metaTestCase.rawParams) + " : ", ".", 80)
? messageLine ; testCase.Result
? messageLine ; testCase.Result ; " (" + stri(metaTestCase.time).trim() +"ms)"
end if
if LCase(testCase.Result) <> "success"
? " | "; insettext ;" |--Location: "; locationText
Expand Down Expand Up @@ -2118,6 +2119,7 @@ sub RBS_RT_RunTestCases(metaTestSuite, itGroup, testSuite, totalStatObj, config,
testSuite.beforeEach()
end if
testTimer = CreateObject("roTimespan")
testCaseTimer = CreateObject("roTimespan")
testStatObj = RBS_STATS_CreateTestStatistic(testCase.Name)
testSuite.testCase = testCase.Func
testStatObj.filePath = metaTestSuite.filePath
Expand All @@ -2139,6 +2141,7 @@ sub RBS_RT_RunTestCases(metaTestSuite, itGroup, testSuite, totalStatObj, config,
end if
testCaseParams.push(paramValue)
end for
testCaseTimer.mark()
if (metaTestCase.expectedNumberOfParams = 1)
testSuite.testCase(testCaseParams[0])
else if (metaTestCase.expectedNumberOfParams = 2)
Expand All @@ -2152,8 +2155,11 @@ sub RBS_RT_RunTestCases(metaTestSuite, itGroup, testSuite, totalStatObj, config,
else if (metaTestCase.expectedNumberOfParams = 6)
testSuite.testCase(testCaseParams[0], testCaseParams[1], testCaseParams[2], testCaseParams[3], testCaseParams[4], testCaseParams[5])
end if
metaTestCase.time = testCaseTimer.totalMilliseconds()
else
testCaseTimer.mark()
testSuite.testCase()
metaTestCase.time = testCaseTimer.totalMilliseconds()
end if
else
testSuite.Fail("Could not parse args for test ")
Expand Down
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.2.0",
"version": "2.3.0",
"description": "simple, flexible, fun brightscript test framework for roku scenegraph apps",
"main": "index.js",
"directories": {
Expand Down
12 changes: 9 additions & 3 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.2.0
' * @version v2.3.0
' * @link https://github.com/georgejecook/rooibos#readme
' * @license MIT
' */
Expand Down Expand Up @@ -1723,6 +1723,7 @@ function UnitTestCase(name as string, func as dynamic, funcName as string, isSol
this.rawParams = params
this.paramTestIndex = paramTestIndex
this.isParamTest = false
this.time = 0
if (params <> invalid)
this.name += stri(this.paramTestIndex)
end if
Expand Down Expand Up @@ -1811,7 +1812,7 @@ sub RBS_LOGGER_PrintTestStatistic(testCase as object)
insetText = ""
if (metaTestcase.isParamTest <> true)
messageLine = RBS_LOGGER_FillText(" " + testChar + " |--" + metaTestCase.Name + " : ", ".", 80)
? messageLine ; testCase.Result
? messageLine ; testCase.Result ; " (" + stri(metaTestCase.time).trim() +"ms)"
else if ( metaTestcase.paramTestIndex = 0)
name = metaTestCase.Name
if (len(name) > 1 and right(name, 1) = "0")
Expand All @@ -1822,7 +1823,7 @@ sub RBS_LOGGER_PrintTestStatistic(testCase as object)
if (metaTestcase.isParamTest = true)
insetText = " "
messageLine = RBS_LOGGER_FillText(" " + testChar + insetText + " |--" + formatJson(metaTestCase.rawParams) + " : ", ".", 80)
? messageLine ; testCase.Result
? messageLine ; testCase.Result ; " (" + stri(metaTestCase.time).trim() +"ms)"
end if
if LCase(testCase.Result) <> "success"
? " | "; insettext ;" |--Location: "; locationText
Expand Down Expand Up @@ -2118,6 +2119,7 @@ sub RBS_RT_RunTestCases(metaTestSuite, itGroup, testSuite, totalStatObj, config,
testSuite.beforeEach()
end if
testTimer = CreateObject("roTimespan")
testCaseTimer = CreateObject("roTimespan")
testStatObj = RBS_STATS_CreateTestStatistic(testCase.Name)
testSuite.testCase = testCase.Func
testStatObj.filePath = metaTestSuite.filePath
Expand All @@ -2139,6 +2141,7 @@ sub RBS_RT_RunTestCases(metaTestSuite, itGroup, testSuite, totalStatObj, config,
end if
testCaseParams.push(paramValue)
end for
testCaseTimer.mark()
if (metaTestCase.expectedNumberOfParams = 1)
testSuite.testCase(testCaseParams[0])
else if (metaTestCase.expectedNumberOfParams = 2)
Expand All @@ -2152,8 +2155,11 @@ sub RBS_RT_RunTestCases(metaTestSuite, itGroup, testSuite, totalStatObj, config,
else if (metaTestCase.expectedNumberOfParams = 6)
testSuite.testCase(testCaseParams[0], testCaseParams[1], testCaseParams[2], testCaseParams[3], testCaseParams[4], testCaseParams[5])
end if
metaTestCase.time = testCaseTimer.totalMilliseconds()
else
testCaseTimer.mark()
testSuite.testCase()
metaTestCase.time = testCaseTimer.totalMilliseconds()
end if
else
testSuite.Fail("Could not parse args for test ")
Expand Down
1 change: 1 addition & 0 deletions src/Rooibos_TestCase.brs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function UnitTestCase(name as string, func as dynamic, funcName as string, isSol
this.rawParams = params
this.paramTestIndex = paramTestIndex
this.isParamTest = false
this.time = 0
if (params <> invalid)
this.name += stri(this.paramTestIndex)
end if
Expand Down
4 changes: 2 additions & 2 deletions src/Rooibos_TestLogger.brs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ sub RBS_LOGGER_PrintTestStatistic(testCase as object)
insetText = ""
if (metaTestcase.isParamTest <> true)
messageLine = RBS_LOGGER_FillText(" " + testChar + " |--" + metaTestCase.Name + " : ", ".", 80)
? messageLine ; testCase.Result
? messageLine ; testCase.Result ; " (" + stri(metaTestCase.time).trim() +"ms)"
else if ( metaTestcase.paramTestIndex = 0)
name = metaTestCase.Name
if (len(name) > 1 and right(name, 1) = "0")
Expand All @@ -116,7 +116,7 @@ sub RBS_LOGGER_PrintTestStatistic(testCase as object)
if (metaTestcase.isParamTest = true)
insetText = " "
messageLine = RBS_LOGGER_FillText(" " + testChar + insetText + " |--" + formatJson(metaTestCase.rawParams) + " : ", ".", 80)
? messageLine ; testCase.Result
? messageLine ; testCase.Result ; " (" + stri(metaTestCase.time).trim() +"ms)"
end if

if LCase(testCase.Result) <> "success"
Expand Down
5 changes: 5 additions & 0 deletions src/Rooibos_TestRunner.brs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ sub RBS_RT_RunTestCases(metaTestSuite, itGroup, testSuite, totalStatObj, config,
end if

testTimer = CreateObject("roTimespan")
testCaseTimer = CreateObject("roTimespan")
testStatObj = RBS_STATS_CreateTestStatistic(testCase.Name)
testSuite.testCase = testCase.Func
testStatObj.filePath = metaTestSuite.filePath
Expand All @@ -274,6 +275,7 @@ sub RBS_RT_RunTestCases(metaTestSuite, itGroup, testSuite, totalStatObj, config,
end if
testCaseParams.push(paramValue)
end for
testCaseTimer.mark()
'up to 6 param args supported for now
if (metaTestCase.expectedNumberOfParams = 1)
testSuite.testCase(testCaseParams[0])
Expand All @@ -288,8 +290,11 @@ sub RBS_RT_RunTestCases(metaTestSuite, itGroup, testSuite, totalStatObj, config,
else if (metaTestCase.expectedNumberOfParams = 6)
testSuite.testCase(testCaseParams[0], testCaseParams[1], testCaseParams[2], testCaseParams[3], testCaseParams[4], testCaseParams[5])
end if
metaTestCase.time = testCaseTimer.totalMilliseconds()
else
testCaseTimer.mark()
testSuite.testCase()
metaTestCase.time = testCaseTimer.totalMilliseconds()
end if
else
testSuite.Fail("Could not parse args for test ")
Expand Down

0 comments on commit f960e52

Please sign in to comment.