@@ -110,12 +110,13 @@ var testsWithLongDelay = {
110
110
testLoadInvalidUrl : 10000
111
111
}
112
112
113
- var duration ;
113
+ var startTime ;
114
114
var running = false ;
115
115
var testsQueue = new Array < TestInfo > ( ) ;
116
116
117
117
function printRunTestStats ( ) {
118
118
let testFileContent = new Array < string > ( ) ;
119
+ let testCases = new Array < string > ( ) ;
119
120
120
121
var j ;
121
122
var failedTestCount = 0 ;
@@ -124,28 +125,32 @@ function printRunTestStats() {
124
125
let allTests = testsQueue . filter ( t => t . isTest ) ;
125
126
126
127
testFileContent . push ( "<testsuites>" ) ;
127
- testFileContent . push ( `<testsuite name="NativeScript Tests" timestamp="${ new Date ( ) } " hostname="hostname" time="0" errors="0" tests="${ allTests . length } " skipped="0" failures="${ failedTestCount } ">` ) ;
128
128
129
129
for ( j = 0 ; j < allTests . length ; j ++ ) {
130
130
let testName = allTests [ j ] . testName ;
131
- let duration = Math . round ( allTests [ j ] . duration / 1000 ) ;
132
-
131
+ let duration = ( allTests [ j ] . duration / 1000 ) . toFixed ( 2 ) ;
132
+
133
133
if ( ! allTests [ j ] . isPassed ) {
134
134
failedTestCount ++ ;
135
135
136
136
let errorMessage = allTests [ j ] . errorMessage ;
137
137
138
138
failedTestInfo . push ( allTests [ j ] . testName + " FAILED: " + allTests [ j ] . errorMessage ) ;
139
139
140
- testFileContent . push ( `<testcase classname="${ platform . device . os } " name="${ testName } " time="${ duration } "><failure type="exceptions.AssertionError"><![CDATA[${ errorMessage } ]]></failure></testcase>` ) ;
140
+ testCases . push ( `<testcase classname="${ platform . device . os } " name="${ testName } " time="${ duration } "><failure type="exceptions.AssertionError"><![CDATA[${ errorMessage } ]]></failure></testcase>` ) ;
141
141
142
142
} else {
143
- testFileContent . push ( `<testcase classname="${ platform . device . os } " name="${ testName } " time="${ duration } "></testcase>` ) ;
143
+ testCases . push ( `<testcase classname="${ platform . device . os } " name="${ testName } " time="${ duration } "></testcase>` ) ;
144
144
}
145
145
}
146
+
147
+ var totalTime = ( TKUnit . time ( ) - startTime ) . toFixed ( 2 ) ;
148
+
149
+ testFileContent . push ( `<testsuite name="NativeScript Tests" timestamp="${ new Date ( ) } " hostname="hostname" time="${ totalTime } " errors="0" tests="${ allTests . length } " skipped="0" failures="${ failedTestCount } ">` ) ;
146
150
151
+ testFileContent = testFileContent . concat ( testCases ) ;
147
152
148
- let finalMessage = `=== ALL TESTS COMPLETE for ${ Math . round ( TKUnit . time ( ) - duration ) } ms === \n${ ( allTests . length - failedTestCount ) } OK, ${ failedTestCount } failed\n` ;
153
+ let finalMessage = `=== ALL TESTS COMPLETE for ${ totalTime } ms === \n${ ( allTests . length - failedTestCount ) } OK, ${ failedTestCount } failed\n` ;
149
154
TKUnit . write ( finalMessage , messageType . info ) ;
150
155
for ( j = 0 ; j < failedTestInfo . length ; j ++ ) {
151
156
let failureMessage = failedTestInfo [ j ] ;
@@ -211,7 +216,7 @@ export var runAll = function (testSelector?: string) {
211
216
212
217
var totalSuccess = 0 ;
213
218
var totalFailed : Array < TKUnit . TestFailure > = [ ] ;
214
- testsQueue . push ( new TestInfo ( ( ) => { running = true ; duration = TKUnit . time ( ) ; } ) ) ;
219
+ testsQueue . push ( new TestInfo ( ( ) => { running = true ; startTime = TKUnit . time ( ) ; } ) ) ;
215
220
for ( var name in allTests ) {
216
221
if ( singleModuleName && ( singleModuleName !== name . toLowerCase ( ) ) ) {
217
222
continue ;
0 commit comments