Below are samples.
public class A {
@BeforeAll
public static void beforeClass() {
}
@BeforeEach
public void setUp() {
}
}
public class B extends A {
@BeforeAll
static void beforeClass() { // Generated lifecycle method will report error "Cannot reduce the visibility of the inherited method from A".
}
@BeforeEach
void setUp() { // Generated lifecycle method will report error "Cannot reduce the visibility of the inherited method from A".
}
}
Should check if the inherited class contains the same methods. If they're visible to the subclass, the subclass should not reduce the visibility of these methods. Also add @Override annotation for them.