junit4: [JUnit 4.13 regression] @BeforeClass shadowing in superclass doesn't work

In JUnit 4.13 version the @BeforeClass method of superclass is run even if it is shadowed by current class, which is not as expected according to current JUnit 4.12 behaviour and @BeforeClass javadoc:

The "@BeforeClass" methods of superclasses will be run before those of the current class,
unless they are shadowed in the current class.

Repro code:

class Junit413RegressionSuperclass {
  @BeforeClass
  public static void beforeAll() {
    System.out.println("beforeAll - superclass");
  }
}

public class Junit413Regression extends Junit413RegressionSuperclass {
  @BeforeClass
  public static void beforeAll() {
    System.out.println("beforeAll - class");
  }

  @Test
  public void test() {
    System.out.println("test - class");
  }
}

Expected output (JUnit 4.12):

beforeAll - class
test - class

Actual output (JUnit 14.13-SNAPSHOT):

beforeAll - superclass
beforeAll - class
test - class

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (12 by maintainers)

Commits related to this issue

Most upvoted comments