@@ -261,6 +261,54 @@ void whenAChildClassInheritsFromABaseClassWithReportingConfig_thenChildClassShou
261
261
262
262
}
263
263
264
+ @ Test
265
+ void whenProceedThrowsAnAssertionError_thenTestShouldNotFail () throws Throwable {
266
+ SampleAnnotatedTest test = new SampleAnnotatedTest ();
267
+
268
+ Method methodMock = test .getClass ().getMethod ("someTestMethod" );
269
+ PerformanceEvaluationStatement statementMock = mock (PerformanceEvaluationStatement .class );
270
+ Invocation <Void > invocationMock = mock (Invocation .class );
271
+ ReflectiveInvocationContext <Method > invocationContextMock = mock (ReflectiveInvocationContext .class );
272
+ ExtensionContext extensionContextMock = mockTestContext ();
273
+
274
+ when (extensionContextMock .getRequiredTestMethod ()).thenReturn (methodMock );
275
+ when (extensionContextMock .getRequiredTestClass ()).thenReturn ((Class ) test .getClass ());
276
+ when (statementBuilderMock .build ()).thenReturn (statementMock );
277
+
278
+ when (invocationMock .proceed ()).thenThrow (new AssertionError ());
279
+
280
+ interceptor .postProcessTestInstance (test , extensionContextMock );
281
+ interceptor .statementBuilder = statementBuilderMock ;
282
+
283
+ assertDoesNotThrow (() -> {
284
+ interceptor .interceptTestMethod (invocationMock , invocationContextMock , extensionContextMock );
285
+ });
286
+ }
287
+
288
+ @ Test
289
+ void whenProceedThrowsAnAssertionError_andTestIsNotAPerfTest_thenTestShouldFail () throws Throwable {
290
+ SampleNoAnnotationsTest test = new SampleNoAnnotationsTest ();
291
+
292
+ Method methodMock = test .getClass ().getMethod ("someTestMethod" );
293
+ PerformanceEvaluationStatement statementMock = mock (PerformanceEvaluationStatement .class );
294
+ Invocation <Void > invocationMock = mock (Invocation .class );
295
+ ReflectiveInvocationContext <Method > invocationContextMock = mock (ReflectiveInvocationContext .class );
296
+ ExtensionContext extensionContextMock = mockTestContext ();
297
+
298
+ when (extensionContextMock .getRequiredTestMethod ()).thenReturn (methodMock );
299
+ when (extensionContextMock .getRequiredTestClass ()).thenReturn ((Class ) test .getClass ());
300
+ when (statementBuilderMock .build ()).thenReturn (statementMock );
301
+
302
+ when (invocationMock .proceed ()).thenThrow (new AssertionError ());
303
+
304
+ interceptor .postProcessTestInstance (test , extensionContextMock );
305
+ interceptor .statementBuilder = statementBuilderMock ;
306
+
307
+ assertThrows (AssertionError .class , () -> {
308
+ interceptor .interceptTestMethod (invocationMock , invocationContextMock , extensionContextMock );
309
+ });
310
+ }
311
+
264
312
@ Test
265
313
void whenInterceptorSupportsParameterIsCalled_thenParameterTypeShouldBeChecked () throws NoSuchMethodException {
266
314
assertTrue (interceptor .supportsParameter (mockTestContextSupplierParameterType (), null ));
0 commit comments