From f960e521b39d07543d987dd7e247a4b6e45638a6 Mon Sep 17 00:00:00 2001 From: George Cook Date: Sat, 27 Apr 2019 19:51:42 -0500 Subject: [PATCH] 2.3.0 - adds ms time for each test in the test output --- CHANGELOG.md | 14 ++++++++++++++ VERSION | 2 +- dist/rooibosDist.brs | 12 +++++++++--- .../source/tests/rooibosDist.brs | 10 ++++++++-- package.json | 2 +- .../example/source/tests/rooibos/rooibosDist.brs | 12 +++++++++--- src/Rooibos_TestCase.brs | 1 + src/Rooibos_TestLogger.brs | 4 ++-- src/Rooibos_TestRunner.brs | 5 +++++ 9 files changed, 50 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8524259..5d28dba4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/VERSION b/VERSION index ccbccc3d..276cbf9e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.2.0 +2.3.0 diff --git a/dist/rooibosDist.brs b/dist/rooibosDist.brs index 9495ed55..b2ba0873 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.2.0 +' * @version v2.3.0 ' * @link https://github.com/georgejecook/rooibos#readme ' * @license MIT ' */ @@ -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 @@ -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") @@ -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 @@ -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 @@ -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) @@ -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 ") diff --git a/outRun/.roku-deploy-staging/source/tests/rooibosDist.brs b/outRun/.roku-deploy-staging/source/tests/rooibosDist.brs index 9495ed55..ce088c6d 100644 --- a/outRun/.roku-deploy-staging/source/tests/rooibosDist.brs +++ b/outRun/.roku-deploy-staging/source/tests/rooibosDist.brs @@ -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 @@ -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") @@ -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 @@ -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 @@ -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) @@ -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 ") diff --git a/package.json b/package.json index 8073cdcd..dfee58d1 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/samples/example/source/tests/rooibos/rooibosDist.brs b/samples/example/source/tests/rooibos/rooibosDist.brs index 9495ed55..b2ba0873 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.2.0 +' * @version v2.3.0 ' * @link https://github.com/georgejecook/rooibos#readme ' * @license MIT ' */ @@ -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 @@ -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") @@ -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 @@ -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 @@ -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) @@ -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 ") diff --git a/src/Rooibos_TestCase.brs b/src/Rooibos_TestCase.brs index 00eb944a..d3ec006d 100644 --- a/src/Rooibos_TestCase.brs +++ b/src/Rooibos_TestCase.brs @@ -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 diff --git a/src/Rooibos_TestLogger.brs b/src/Rooibos_TestLogger.brs index 13596b61..78afe08e 100644 --- a/src/Rooibos_TestLogger.brs +++ b/src/Rooibos_TestLogger.brs @@ -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") @@ -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" diff --git a/src/Rooibos_TestRunner.brs b/src/Rooibos_TestRunner.brs index 0958eb1d..2ab7f9bb 100644 --- a/src/Rooibos_TestRunner.brs +++ b/src/Rooibos_TestRunner.brs @@ -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 @@ -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]) @@ -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 ")