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
- Fix GCS integration tests with JUnit 4.13. Context: https://github.com/junit-team/junit4/issues/1509 Change on 2018/02/28 by idv <idv@google.com> ------------- Created by MOE: https://github.com/g... — committed to GoogleCloudDataproc/hadoop-connectors by medb 6 years ago
- Fix GCS integration tests with JUnit 4.13. Context: https://github.com/junit-team/junit4/issues/1509 Change on 2018/02/28 by idv <idv@google.com> ------------- Created by MOE: https://github.com/g... — committed to GoogleCloudDataproc/hadoop-connectors by medb 6 years ago
- Fix GCS integration tests with JUnit 4.13. Context: https://github.com/junit-team/junit4/issues/1509 Change on 2018/02/28 by idv <idv@google.com> ------------- Created by MOE: https://github.com/g... — committed to GoogleCloudDataproc/hadoop-connectors by medb 6 years ago
- Fix GCS integration tests with JUnit 4.13. Context: https://github.com/junit-team/junit4/issues/1509 Change on 2018/02/28 by idv <idv@google.com> ------------- Created by MOE: https://github.com/g... — committed to mayanks/hadoop-connectors by medb 6 years ago
To make things concrete, here’s one possible fix:
https://github.com/junit-team/junit4/commit/5ef2b8de3d751b7e06cf81dcbf64a155fe490e0a