File tree Expand file tree Collapse file tree 2 files changed +36
-6
lines changed Expand file tree Collapse file tree 2 files changed +36
-6
lines changed Original file line number Diff line number Diff line change @@ -107,18 +107,22 @@ TestSuite.prototype.initAfterEachHook = function() {
107
107
var key = 'afterEach' ;
108
108
var hookFn ;
109
109
var index = self . testResults . steps . indexOf ( key ) ;
110
- if ( index === - 1 ) {
110
+
111
+ if ( ! module [ key ] ) {
111
112
// backwards compatibility
112
113
key = 'tearDown' ;
113
114
index = self . testResults . steps . indexOf ( key ) ;
114
115
}
115
116
116
- if ( index === - 1 ) {
117
- hookFn = function ( ) { } ;
118
- } else {
117
+ if ( module [ key ] ) {
119
118
hookFn = module [ key ] ;
120
- self . testResults . steps . splice ( index , 1 ) ;
121
- self . module . removeKey ( key ) ;
119
+ if ( index > - 1 ) {
120
+ // not running with --testcase
121
+ self . testResults . steps . splice ( index , 1 ) ;
122
+ self . module . removeKey ( key ) ;
123
+ }
124
+ } else {
125
+ hookFn = function ( ) { } ;
122
126
}
123
127
124
128
var expectedArgs = hookFn . length ;
Original file line number Diff line number Diff line change @@ -605,6 +605,32 @@ module.exports = {
605
605
} ) ;
606
606
} ,
607
607
608
+ testRunTestCaseWithBeforeAndAfter : function ( test ) {
609
+ var testsPath = path . join ( process . cwd ( ) , '/sampletests/before-after/syncBeforeAndAfter.js' ) ;
610
+ test . expect ( 11 ) ;
611
+ this . Runner . run ( [ testsPath ] , {
612
+ seleniumPort : 10195 ,
613
+ silent : true ,
614
+ output : false ,
615
+ globals : {
616
+ test : test
617
+ }
618
+ } , {
619
+ output_folder : false ,
620
+ start_session : true ,
621
+ testcase : 'demoTestSyncOne'
622
+ } , function ( err , results ) {
623
+ test . equals ( err , null ) ;
624
+ var result = results . modules . syncBeforeAndAfter . completed ;
625
+ test . ok ( 'demoTestSyncOne' in result ) ;
626
+ test . ok ( ! ( 'beforeEach' in result ) ) ;
627
+ test . ok ( ! ( 'before' in result ) ) ;
628
+ test . ok ( ! ( 'afterEach' in result ) ) ;
629
+ test . ok ( ! ( 'after' in result ) ) ;
630
+ test . done ( ) ;
631
+ } ) ;
632
+ } ,
633
+
608
634
testRunTestcaseInvalid : function ( test ) {
609
635
var testsPath = path . join ( process . cwd ( ) , '/sampletests/before-after/syncBeforeAndAfter.js' ) ;
610
636
You can’t perform that action at this time.
0 commit comments