@@ -82,9 +82,9 @@ void classLevelExceptionHandlersRethrowException() {
82
82
LauncherDiscoveryRequest request = request ().selectors (selectClass (RethrowingTestCase .class )).build ();
83
83
EngineExecutionResults executionResults = executeTests (request );
84
84
85
- assertEquals (1 , RethrowExceptionHandler .callCounter .getBeforeAllCalls () ,
85
+ assertEquals (1 , RethrowExceptionHandler .callCounter .beforeAllCalls ,
86
86
"Exception should handled in @BeforeAll" );
87
- assertEquals (1 , RethrowExceptionHandler .callCounter .getAfterAllCalls () ,
87
+ assertEquals (1 , RethrowExceptionHandler .callCounter .afterAllCalls ,
88
88
"Exception should handled in @AfterAll" );
89
89
90
90
executionResults .allEvents ().assertEventsMatchExactly ( //
@@ -101,9 +101,9 @@ void testLevelExceptionHandlersRethrowException() {
101
101
LauncherDiscoveryRequest request = request ().selectors (selectClass (RethrowingTestCase .class )).build ();
102
102
EngineExecutionResults executionResults = executeTests (request );
103
103
104
- assertEquals (1 , RethrowExceptionHandler .callCounter .getBeforeEachCalls () ,
104
+ assertEquals (1 , RethrowExceptionHandler .callCounter .beforeEachCalls ,
105
105
"Exception should be handled in @BeforeEach" );
106
- assertEquals (1 , RethrowExceptionHandler .callCounter .getAfterEachCalls () ,
106
+ assertEquals (1 , RethrowExceptionHandler .callCounter .afterEachCalls ,
107
107
"Exception should be handled in @AfterEach" );
108
108
109
109
executionResults .allEvents ().assertEventsMatchExactly ( //
@@ -120,9 +120,9 @@ void classLevelExceptionHandlersConvertException() {
120
120
LauncherDiscoveryRequest request = request ().selectors (selectClass (ConvertingTestCase .class )).build ();
121
121
EngineExecutionResults executionResults = executeTests (request );
122
122
123
- assertEquals (1 , ConvertExceptionHandler .callCounter .getBeforeAllCalls () ,
123
+ assertEquals (1 , ConvertExceptionHandler .callCounter .beforeAllCalls ,
124
124
"Exception should handled in @BeforeAll" );
125
- assertEquals (1 , ConvertExceptionHandler .callCounter .getAfterAllCalls () ,
125
+ assertEquals (1 , ConvertExceptionHandler .callCounter .afterAllCalls ,
126
126
"Exception should handled in @AfterAll" );
127
127
128
128
executionResults .allEvents ().assertEventsMatchExactly ( //
@@ -139,9 +139,9 @@ void testLevelExceptionHandlersConvertException() {
139
139
LauncherDiscoveryRequest request = request ().selectors (selectClass (ConvertingTestCase .class )).build ();
140
140
EngineExecutionResults executionResults = executeTests (request );
141
141
142
- assertEquals (1 , ConvertExceptionHandler .callCounter .getBeforeEachCalls () ,
142
+ assertEquals (1 , ConvertExceptionHandler .callCounter .beforeEachCalls ,
143
143
"Exception should be handled in @BeforeEach" );
144
- assertEquals (1 , ConvertExceptionHandler .callCounter .getAfterEachCalls () ,
144
+ assertEquals (1 , ConvertExceptionHandler .callCounter .afterEachCalls ,
145
145
"Exception should be handled in @AfterEach" );
146
146
147
147
executionResults .allEvents ().assertEventsMatchExactly ( //
@@ -158,13 +158,13 @@ void exceptionHandlersSwallowException() {
158
158
LauncherDiscoveryRequest request = request ().selectors (selectClass (SwallowingTestCase .class )).build ();
159
159
EngineExecutionResults executionResults = executeTests (request );
160
160
161
- assertEquals (1 , SwallowExceptionHandler .callCounter .getBeforeAllCalls () ,
161
+ assertEquals (1 , SwallowExceptionHandler .callCounter .beforeAllCalls ,
162
162
"Exception should be handled in @BeforeAll" );
163
- assertEquals (1 , SwallowExceptionHandler .callCounter .getBeforeEachCalls () ,
163
+ assertEquals (1 , SwallowExceptionHandler .callCounter .beforeEachCalls ,
164
164
"Exception should be handled in @BeforeEach" );
165
- assertEquals (1 , SwallowExceptionHandler .callCounter .getAfterEachCalls () ,
165
+ assertEquals (1 , SwallowExceptionHandler .callCounter .afterEachCalls ,
166
166
"Exception should be handled in @AfterEach" );
167
- assertEquals (1 , SwallowExceptionHandler .callCounter .getAfterAllCalls () ,
167
+ assertEquals (1 , SwallowExceptionHandler .callCounter .afterAllCalls ,
168
168
"Exception should be handled in @AfterAll" );
169
169
170
170
executionResults .allEvents ().assertEventsMatchExactly ( //
@@ -180,13 +180,13 @@ void exceptionHandlersSwallowException() {
180
180
void perClassLifecycleMethodsAreHandled () {
181
181
LauncherDiscoveryRequest request = request ().selectors (selectClass (PerClassLifecycleTestCase .class )).build ();
182
182
EngineExecutionResults executionResults = executeTests (request );
183
- assertEquals (2 , SwallowExceptionHandler .callCounter .getBeforeAllCalls () ,
183
+ assertEquals (2 , SwallowExceptionHandler .callCounter .beforeAllCalls ,
184
184
"Exception should be handled in @BeforeAll" );
185
- assertEquals (1 , SwallowExceptionHandler .callCounter .getBeforeEachCalls () ,
185
+ assertEquals (1 , SwallowExceptionHandler .callCounter .beforeEachCalls ,
186
186
"Exception should be handled in @BeforeEach" );
187
- assertEquals (1 , SwallowExceptionHandler .callCounter .getAfterEachCalls () ,
187
+ assertEquals (1 , SwallowExceptionHandler .callCounter .afterEachCalls ,
188
188
"Exception should be handled in @AfterEach" );
189
- assertEquals (2 , SwallowExceptionHandler .callCounter .getAfterAllCalls () ,
189
+ assertEquals (2 , SwallowExceptionHandler .callCounter .afterAllCalls ,
190
190
"Exception should be handled in @AfterAll" );
191
191
192
192
executionResults .allEvents ().assertEventsMatchExactly ( //
@@ -238,9 +238,9 @@ void unrecoverableExceptionsAreNotPropagatedInBeforeAll() {
238
238
239
239
boolean unrecoverableExceptionThrown = executeThrowingOutOfMemoryException ();
240
240
assertTrue (unrecoverableExceptionThrown , "Unrecoverable Exception should be thrown" );
241
- assertEquals (1 , UnrecoverableExceptionHandler .callCounter .getBeforeAllCalls () ,
241
+ assertEquals (1 , UnrecoverableExceptionHandler .callCounter .beforeAllCalls ,
242
242
"Exception should be handled in @BeforeAll" );
243
- assertEquals (0 , ShouldNotBeCalledHandler .callCounter .getBeforeAllCalls () ,
243
+ assertEquals (0 , ShouldNotBeCalledHandler .callCounter .beforeAllCalls ,
244
244
"Exception should not propagate in @BeforeAll" );
245
245
}
246
246
@@ -253,9 +253,9 @@ void unrecoverableExceptionsAreNotPropagatedInBeforeEach() {
253
253
254
254
boolean unrecoverableExceptionThrown = executeThrowingOutOfMemoryException ();
255
255
assertTrue (unrecoverableExceptionThrown , "Unrecoverable Exception should be thrown" );
256
- assertEquals (1 , UnrecoverableExceptionHandler .callCounter .getBeforeEachCalls () ,
256
+ assertEquals (1 , UnrecoverableExceptionHandler .callCounter .beforeEachCalls ,
257
257
"Exception should be handled in @BeforeEach" );
258
- assertEquals (0 , ShouldNotBeCalledHandler .callCounter .getBeforeEachCalls () ,
258
+ assertEquals (0 , ShouldNotBeCalledHandler .callCounter .beforeEachCalls ,
259
259
"Exception should not propagate in @BeforeEach" );
260
260
}
261
261
@@ -268,9 +268,9 @@ void unrecoverableExceptionsAreNotPropagatedInAfterEach() {
268
268
269
269
boolean unrecoverableExceptionThrown = executeThrowingOutOfMemoryException ();
270
270
assertTrue (unrecoverableExceptionThrown , "Unrecoverable Exception should be thrown" );
271
- assertEquals (1 , UnrecoverableExceptionHandler .callCounter .getAfterEachCalls () ,
271
+ assertEquals (1 , UnrecoverableExceptionHandler .callCounter .afterEachCalls ,
272
272
"Exception should be handled in @AfterEach" );
273
- assertEquals (0 , ShouldNotBeCalledHandler .callCounter .getAfterEachCalls () ,
273
+ assertEquals (0 , ShouldNotBeCalledHandler .callCounter .afterEachCalls ,
274
274
"Exception should not propagate in @AfterEach" );
275
275
}
276
276
@@ -283,9 +283,9 @@ void unrecoverableExceptionsAreNotPropagatedInAfterAll() {
283
283
284
284
boolean unrecoverableExceptionThrown = executeThrowingOutOfMemoryException ();
285
285
assertTrue (unrecoverableExceptionThrown , "Unrecoverable Exception should be thrown" );
286
- assertEquals (1 , UnrecoverableExceptionHandler .callCounter .getAfterAllCalls () ,
286
+ assertEquals (1 , UnrecoverableExceptionHandler .callCounter .afterAllCalls ,
287
287
"Exception should be handled in @AfterAll" );
288
- assertEquals (0 , ShouldNotBeCalledHandler .callCounter .getAfterAllCalls () ,
288
+ assertEquals (0 , ShouldNotBeCalledHandler .callCounter .afterAllCalls ,
289
289
"Exception should not propagate in @AfterAll" );
290
290
}
291
291
@@ -561,4 +561,40 @@ public void handleAfterAllMethodExecutionException(ExtensionContext context, Thr
561
561
throw throwable ;
562
562
}
563
563
}
564
+
565
+ class HandlerCallCounter {
566
+ private int beforeAllCalls ;
567
+ private int beforeEachCalls ;
568
+ private int afterEachCalls ;
569
+ private int afterAllCalls ;
570
+
571
+ public HandlerCallCounter () {
572
+ reset ();
573
+ }
574
+
575
+ public void reset () {
576
+ this .beforeAllCalls = 0 ;
577
+ this .beforeEachCalls = 0 ;
578
+ this .afterEachCalls = 0 ;
579
+ this .afterAllCalls = 0 ;
580
+ }
581
+
582
+ public void incrementBeforeAllCalls () {
583
+ beforeAllCalls ++;
584
+ }
585
+
586
+ public void incrementBeforeEachCalls () {
587
+ beforeEachCalls ++;
588
+ }
589
+
590
+ public void incrementAfterEachCalls () {
591
+ afterEachCalls ++;
592
+ }
593
+
594
+ public void incrementAfterAllCalls () {
595
+ afterAllCalls ++;
596
+ }
597
+
598
+
599
+ }
564
600
}
0 commit comments