@@ -74,6 +74,13 @@ class TestHelper {
74
74
this . _devices = null ;
75
75
this . _success = true ;
76
76
77
+ this . _testFailures = [ ] ;
78
+ this . _testMethod = null ;
79
+ this . _testFile = null ;
80
+ this . _tests = 0 ;
81
+ this . _assertions = 0 ;
82
+ this . _failures = 0 ;
83
+
77
84
TestDebugMixin . call ( this ) ;
78
85
this . _init ( options ) ;
79
86
@@ -141,19 +148,30 @@ class TestHelper {
141
148
return this . _runTestOnDeviceGroup ( testFile ) ;
142
149
} ) ,
143
150
Promise . resolve ( ) ) ) . then ( ( ) => {
144
- if ( this . _stopCommand ) {
145
- this . _debug ( UserInteractor . MESSAGES . TEST_STOP ) ;
146
- }
147
- return Promise . resolve ( ) ;
148
- } ) . then ( ( ) => {
149
- this . _blank ( ) ;
150
-
151
- if ( this . _success ) {
152
- this . _info ( c . green ( UserInteractor . MESSAGES . TEST_SUCCEEDED ) ) ;
153
- } else {
154
- this . _info ( c . red ( UserInteractor . ERRORS . TEST_FAILED ) ) ;
155
- }
156
- } ) ;
151
+ if ( this . _stopCommand ) {
152
+ this . _debug ( UserInteractor . MESSAGES . TEST_STOP ) ;
153
+ }
154
+ return Promise . resolve ( ) ;
155
+ } ) . then ( ( ) => {
156
+ this . _blank ( ) ;
157
+ this . _info ( UserInteractor . MESSAGES . TEST_SUMMARY_HEADER ) ;
158
+ this . _blank ( ) ;
159
+ this . _testFailures . forEach ( ( item , index ) => {
160
+ this . _info ( Util . format ( UserInteractor . MESSAGES . TEST_SUMMARY_FAILURE , index + 1 , item . test ) ) ;
161
+ this . _info ( Util . format ( UserInteractor . MESSAGES . TEST_SUMMARY_AT , item . file ) ) ;
162
+ this . _info ( Util . format ( UserInteractor . MESSAGES . TEST_SUMMARY_ERROR , item . result ) ) ;
163
+ this . _blank ( ) ;
164
+ } ) ;
165
+ this . _info ( Util . format ( UserInteractor . MESSAGES . TEST_SESSION_RESULT , this . _tests , this . _assertions , this . _failures ) ) ;
166
+ this . _info ( UserInteractor . MESSAGES . TEST_SUMMARY_FOOTER ) ;
167
+ this . _blank ( ) ;
168
+
169
+ if ( this . _success ) {
170
+ this . _info ( c . green ( UserInteractor . MESSAGES . TEST_SUCCEEDED ) ) ;
171
+ } else {
172
+ this . _info ( c . red ( UserInteractor . ERRORS . TEST_FAILED ) ) ;
173
+ }
174
+ } ) ;
157
175
}
158
176
159
177
_runTestOnDeviceGroup ( testFile ) {
@@ -201,7 +219,7 @@ class TestHelper {
201
219
if ( testIsAgentOnly ) {
202
220
this . _info ( UserInteractor . MESSAGES . TEST_AGENT_ONLY ) ;
203
221
}
204
- this . _info ( Util . format ( UserInteractor . MESSAGES . TEST_USE_DEVICE ,
222
+ this . _info ( Util . format ( UserInteractor . MESSAGES . TEST_USE_DEVICE ,
205
223
device . name ? device . name : '' , device . id , deviceIndex , this . _devices . length ) ) ;
206
224
207
225
// check online state
@@ -219,7 +237,7 @@ class TestHelper {
219
237
// run test session
220
238
return this . _runSession ( device , testFile . type , this . _deviceGroup )
221
239
222
- // error
240
+ // error
223
241
. catch ( ( error ) => {
224
242
this . _onError ( error ) ;
225
243
} )
@@ -315,7 +333,7 @@ class TestHelper {
315
333
}
316
334
317
335
for ( const searchPattern of searchPatterns ) {
318
- for ( const file of glob . sync ( searchPattern , { cwd : configCwd } ) ) {
336
+ for ( const file of glob . sync ( searchPattern , { cwd : configCwd } ) ) {
319
337
// TODO: would it better to add the testFileName to the searchPatterns?
320
338
if ( testFileName != null && testFileName . length > 0 && file . search ( testFileName ) < 0 ) {
321
339
this . _debug ( Util . format ( UserInteractor . MESSAGES . TEST_SKIP_TEST , file ) ) ;
@@ -340,6 +358,9 @@ class TestHelper {
340
358
_getSessionCode ( testFile ) {
341
359
let agentCode , deviceCode ;
342
360
361
+ // save current test file name
362
+ this . _testFile = testFile . name ;
363
+
343
364
// [info]
344
365
this . _info ( Util . format ( UserInteractor . MESSAGES . TEST_USE_FILE , testFile . type , testFile . name ) ) ;
345
366
@@ -560,6 +581,7 @@ ${'partnerpath' in testFile ? '@include "' + backslashToSlash(testFile.partnerpa
560
581
561
582
this . _session . on ( 'message' , ( e ) => {
562
583
if ( 'test' === e . type ) {
584
+ this . _testMethod = e . message ;
563
585
this . _testLine ( e . message ) ;
564
586
} else if ( 'externalCommandOutput' === e . type ) {
565
587
this . _print ( e . message ) ;
@@ -594,6 +616,9 @@ ${'partnerpath' in testFile ? '@include "' + backslashToSlash(testFile.partnerpa
594
616
this . _session . on ( 'done' , ( ) => {
595
617
this . _sessionStartWatchdog . stop ( ) ;
596
618
this . _sessionTestMessagesWatchdog . stop ( ) ;
619
+ this . _tests += this . _session . tests ;
620
+ this . _failures += this . _session . failures ;
621
+ this . _assertions += this . _session . assertions ;
597
622
resolve ( ) ;
598
623
} ) ;
599
624
@@ -613,10 +638,9 @@ ${'partnerpath' in testFile ? '@include "' + backslashToSlash(testFile.partnerpa
613
638
this . _debug ( Util . format ( UserInteractor . MESSAGES . TEST_ERROR_TYPE , error . constructor . name ) ) ;
614
639
615
640
if ( error instanceof TestSession . Errors . TestMethodError ) {
616
-
617
641
this . _testLine ( c . red ( Util . format ( UserInteractor . MESSAGES . TEST_FAILURE , error . message ) ) ) ;
642
+ this . _testFailures . push ( { file : this . _testFile , test : this . _testMethod , result : error . message } ) ;
618
643
this . _stopSession = this . _testConfig . stopOnFail ;
619
-
620
644
} else if ( error instanceof TestSession . Errors . TestStateError ) {
621
645
622
646
this . _error ( error ) ;
0 commit comments