1010
1111package org .junit .jupiter .engine ;
1212
13- import static org .junit .jupiter .api .Assertions .assertAll ;
14- import static org .junit .jupiter .api .Assertions .assertEquals ;
1513import static org .junit .jupiter .api .Assertions .fail ;
14+ import static org .junit .platform .testkit .engine .EventConditions .event ;
15+ import static org .junit .platform .testkit .engine .EventConditions .skippedWithReason ;
16+ import static org .junit .platform .testkit .engine .EventConditions .test ;
17+
18+ import java .lang .reflect .Method ;
1619
1720import org .junit .jupiter .api .Disabled ;
1821import org .junit .jupiter .api .Test ;
1922import org .junit .platform .testkit .engine .EngineExecutionResults ;
20- import org .junit .platform .testkit .engine .Events ;
2123
2224/**
23- * Integration tests that verify support for {@link Disabled @Disabled} in the {@link JupiterTestEngine}.
25+ * Integration tests that verify support for {@link Disabled @Disabled} in the
26+ * {@link JupiterTestEngine}.
2427 *
2528 * @since 5.0
2629 */
@@ -36,28 +39,13 @@ void executeTestsWithDisabledTestClass() {
3639
3740 @ Test
3841 void executeTestsWithDisabledTestMethods () throws Exception {
39- Events tests = executeTestsForClass (DisabledTestMethodsTestCase .class ).tests ();
40-
41- // MANUAL APPROACH for asserting statistics
42- //
43- // @formatter:off
44- assertAll (
45- () -> assertEquals (1 , tests .started ().count (), "# tests started" ),
46- () -> assertEquals (1 , tests .skipped ().count (), "# tests skipped" ),
47- () -> assertEquals (1 , tests .finished ().count (), "# tests finished" ),
48- () -> assertEquals (0 , tests .aborted ().count (), "# tests aborted" ),
49- () -> assertEquals (1 , tests .succeeded ().count (), "# tests succeeded" ),
50- () -> assertEquals (0 , tests .failed ().count (), "# tests failed" )
51- );
52- // @formatter:on
53-
54- // BUILT-IN APPROACH for asserting statistics
55- //
56- tests .assertStatistics (stats -> stats .skipped (1 ).started (1 ).finished (1 ).aborted (0 ).succeeded (1 ).failed (0 ));
57-
58- String method = DisabledTestMethodsTestCase .class .getDeclaredMethod ("disabledTest" ).toString ();
59- String reason = tests .skipped ().map (e -> e .getRequiredPayload (String .class )).findFirst ().orElse (null );
60- assertEquals (method + " is @Disabled" , reason );
42+ String methodName = "disabledTest" ;
43+ Method method = DisabledTestMethodsTestCase .class .getDeclaredMethod (methodName );
44+
45+ executeTestsForClass (DisabledTestMethodsTestCase .class ).tests ()//
46+ .assertStatistics (stats -> stats .skipped (1 ).started (1 ).finished (1 ).aborted (0 ).succeeded (1 ).failed (0 ))//
47+ .skipped ().assertEventsMatchExactly (
48+ event (test (methodName ), skippedWithReason (method + " is @Disabled" )));
6149 }
6250
6351 // -------------------------------------------------------------------
0 commit comments