@@ -37,11 +37,13 @@ private LifecycleMethodUtils() {
3737 }
3838
3939 static List <Method > findBeforeAllMethods (Class <?> testClass , boolean requireStatic ) {
40- return findMethodsAndAssertStatic (testClass , requireStatic , BeforeAll .class , HierarchyTraversalMode .TOP_DOWN );
40+ return findMethodsAndAssertStaticAndNonPrivate (testClass , requireStatic , BeforeAll .class ,
41+ HierarchyTraversalMode .TOP_DOWN );
4142 }
4243
4344 static List <Method > findAfterAllMethods (Class <?> testClass , boolean requireStatic ) {
44- return findMethodsAndAssertStatic (testClass , requireStatic , AfterAll .class , HierarchyTraversalMode .BOTTOM_UP );
45+ return findMethodsAndAssertStaticAndNonPrivate (testClass , requireStatic , AfterAll .class ,
46+ HierarchyTraversalMode .BOTTOM_UP );
4547 }
4648
4749 static List <Method > findBeforeEachMethods (Class <?> testClass ) {
@@ -81,12 +83,14 @@ private static void assertVoid(Class<? extends Annotation> annotationType, Metho
8183 }
8284 }
8385
84- private static List <Method > findMethodsAndAssertStatic (Class <?> testClass , boolean requireStatic ,
86+ private static List <Method > findMethodsAndAssertStaticAndNonPrivate (Class <?> testClass , boolean requireStatic ,
8587 Class <? extends Annotation > annotationType , HierarchyTraversalMode traversalMode ) {
8688 List <Method > methods = findMethodsAndCheckVoidReturnType (testClass , annotationType , traversalMode );
8789 if (requireStatic ) {
8890 methods .forEach (method -> assertStatic (annotationType , method ));
8991 }
92+ methods .forEach (method -> assertNonPrivate (annotationType , method ));
93+
9094 return methods ;
9195 }
9296
0 commit comments