From 8f5a621c2ae5e7936e7949ea1cf2870ad130a372 Mon Sep 17 00:00:00 2001 From: Vladimir Enchev Date: Wed, 13 Apr 2016 14:10:07 +0300 Subject: [PATCH] test-results xml improved --- apps/tests/testRunner.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/apps/tests/testRunner.ts b/apps/tests/testRunner.ts index ffdd3ef1a..9ca99dea0 100644 --- a/apps/tests/testRunner.ts +++ b/apps/tests/testRunner.ts @@ -110,12 +110,13 @@ var testsWithLongDelay = { testLoadInvalidUrl: 10000 } -var duration; +var startTime; var running = false; var testsQueue = new Array(); function printRunTestStats() { let testFileContent = new Array(); + let testCases = new Array(); var j; var failedTestCount = 0; @@ -124,12 +125,11 @@ function printRunTestStats() { let allTests = testsQueue.filter(t=> t.isTest); testFileContent.push(""); - testFileContent.push(``); for (j = 0; j < allTests.length; j++) { let testName = allTests[j].testName; - let duration = Math.round(allTests[j].duration / 1000); - + let duration = (allTests[j].duration / 1000).toFixed(2); + if (!allTests[j].isPassed) { failedTestCount++; @@ -137,15 +137,20 @@ function printRunTestStats() { failedTestInfo.push(allTests[j].testName + " FAILED: " + allTests[j].errorMessage); - testFileContent.push(``); + testCases.push(``); } else { - testFileContent.push(``); + testCases.push(``); } } + + var totalTime = (TKUnit.time() - startTime).toFixed(2); + + testFileContent.push(``); + testFileContent = testFileContent.concat(testCases); - let finalMessage = `=== ALL TESTS COMPLETE for ${Math.round(TKUnit.time() - duration)} ms === \n${(allTests.length - failedTestCount)} OK, ${failedTestCount} failed\n`; + let finalMessage = `=== ALL TESTS COMPLETE for ${totalTime} ms === \n${(allTests.length - failedTestCount)} OK, ${failedTestCount} failed\n`; TKUnit.write(finalMessage, messageType.info); for (j = 0; j < failedTestInfo.length; j++) { let failureMessage = failedTestInfo[j]; @@ -211,7 +216,7 @@ export var runAll = function (testSelector?: string) { var totalSuccess = 0; var totalFailed: Array = []; - testsQueue.push(new TestInfo(() => { running = true; duration = TKUnit.time(); })); + testsQueue.push(new TestInfo(() => { running = true; startTime = TKUnit.time(); })); for (var name in allTests) { if (singleModuleName && (singleModuleName !== name.toLowerCase())) { continue;