File tree Expand file tree Collapse file tree 3 files changed +53
-1
lines changed Expand file tree Collapse file tree 3 files changed +53
-1
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ module.exports = class Results {
49
49
this . buildName = capabilities . buildName || desiredCapabilities . buildName || '' ;
50
50
const { webdriver = { } } = settings ;
51
51
this . host = webdriver . host || '' ;
52
+ this . __retryTest = false ;
52
53
53
54
this . initCount ( tests ) ;
54
55
}
@@ -271,12 +272,20 @@ module.exports = class Results {
271
272
return this . currentTestName ;
272
273
}
273
274
275
+ set retryTest ( value ) {
276
+ this . __retryTest = value ;
277
+ }
278
+
279
+ get retryTest ( ) {
280
+ return this . __retryTest ;
281
+ }
282
+
274
283
/**
275
284
* @param {TestCase } testcase
276
285
* @return {Object }
277
286
*/
278
287
createTestCaseResults ( testcase ) {
279
- return {
288
+ const result = {
280
289
time : 0 ,
281
290
assertions : [ ] ,
282
291
commands : [ ] ,
@@ -288,6 +297,22 @@ module.exports = class Results {
288
297
tests : 0 ,
289
298
status : Results . TEST_PASS
290
299
} ;
300
+
301
+ if ( this . retryTest && this . testSections [ testcase . testName ] ) {
302
+ const retryTestData = this . testSections [ testcase . testName ] ;
303
+
304
+ result [ 'retryTestData' ] = [ retryTestData ] ;
305
+
306
+ if ( retryTestData [ 'retryTestData' ] ) {
307
+ result [ 'retryTestData' ] . push ( ...retryTestData [ 'retryTestData' ] ) ;
308
+
309
+ delete retryTestData [ 'retryTestData' ] ;
310
+ }
311
+
312
+ this . retryTest = false ;
313
+ }
314
+
315
+ return result ;
291
316
}
292
317
293
318
resetLastError ( ) {
Original file line number Diff line number Diff line change @@ -803,6 +803,7 @@ class TestSuite {
803
803
let currentTestName = this . testcase . testName ;
804
804
this . suiteRetries . incrementTestRetriesCount ( currentTestName ) ;
805
805
this . reporter . resetCurrentTestPassedCount ( ) ;
806
+ this . reporter . testResults . retryTest = true ;
806
807
this . commandQueue . clearScheduled ( ) ;
807
808
808
809
return this . runCurrentTest ( currentTestName ) ;
Original file line number Diff line number Diff line change @@ -394,4 +394,30 @@ describe('testReporter', function() {
394
394
assert . deepStrictEqual ( result , [ 'nightwatch_reporter_output' , 'html_reporter_output' ] ) ;
395
395
} ) ;
396
396
} ) ;
397
+
398
+ it ( 'test to check retry data logging' , function ( ) {
399
+ this . timeout ( 100000 ) ;
400
+
401
+ const testsPath = path . join ( __dirname , '../../sampletests/withfailures' ) ;
402
+ const globals = {
403
+ calls : 0 ,
404
+ reporter ( results , cb ) {
405
+ assert . ok ( 'sample' in results . modules ) ;
406
+ assert . ok ( 'completedSections' in results . modules [ 'sample' ] ) ;
407
+ assert . ok ( 'demoTest' in results . modules [ 'sample' ] [ 'completedSections' ] ) ;
408
+ assert . ok ( 'retryTestData' in results . modules [ 'sample' ] [ 'completedSections' ] [ 'demoTest' ] ) ;
409
+ assert . ok ( results . modules [ 'sample' ] [ 'completedSections' ] [ 'demoTest' ] [ 'retryTestData' ] . length <= 3 ) ;
410
+ cb ( ) ;
411
+ } ,
412
+ retryAssertionTimeout : 0
413
+ } ;
414
+
415
+ return runTests ( {
416
+ retries : 3 ,
417
+ _source : [ testsPath ]
418
+ } , settings ( {
419
+ skip_testcases_on_fail : false ,
420
+ globals
421
+ } ) ) ;
422
+ } ) ;
397
423
} ) ;
You can’t perform that action at this time.
0 commit comments