-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@BeforeAll
methods with same signature in superclass and subclass are called in JUnit 5.11, but not in JUnit 5.10
#4052
Comments
@BeforeAll
s with the same static method name in a parent class and its inherited class are called in JUnit 5.11, but not in JUnit 5.10@BeforeAll
s with the same static method names in a parent class and its inherited class are called in JUnit 5.11, but not in JUnit 5.10
Hi @tomtongue, Sorry to ask the obvious, but did you read the release notes for JUnit 5.11 before posting this question?
This is intentional, and it's very well documented.
Yes, you can revert to "legacy" mode, which is also documented in the User Guide. In light of the above, I am closing this issue. Regards, Sam |
@BeforeAll
s with the same static method names in a parent class and its inherited class are called in JUnit 5.11, but not in JUnit 5.10@BeforeAll
methods with same signature in superclass and subclass are called in JUnit 5.11, but not in JUnit 5.10
@sbrannen Thanks so much for pointing these documents. Just one thing, I set the legacy semantics to true, but it seems not to work for those static methods. https://github.com/junit-team/junit5/blob/main/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ReflectionUtils.java this code only has the legacy mode only for fields. Please correct me if I'm wrong. |
You're welcome.
The |
Thank you for sharing the flag, sorry I missed that. Thanks so much, let me check those documents again. |
After upgrading to JUnit 5.11, if a testbase class has a static method with the
@BeforeAll
annotation and its inherited testbase class also has the static method (with the same method name as its parent class) with the@BeforeAll
annotation, both of the static methods with the@BeforeAll
annotation are called. However, in Junit 5.10, only the 2nd static method with@BeforeAll
is called.I would like to ask if it's intended, and if it's intended, is there any way to suppress calling the first static method with the
@BeforeAll
annotation?Steps to reproduce
Assuming the following class structure, the actual tests are in the
TestA
class.When you run the tests in
TestA
,@BeforeAll
in theTestBase
class is called, then the same name static method with@BeforeAll
in theFeature1TestBase
class is called.@BeforeAll
in theFeature1TestBase
class is called, the static method in theTestBase
class is NOT called.The below shows more details:
Code
TestBase
:Feature1TestBase
:TestA
:Output
JUnit 5.11.1:
JUnit 5.10.5:
Context
org.junit.jupiter:junit-jupiter:5.11.1
andorg.junit.jupiter:junit-jupiter:5.10.5
)Deliverables
n/a
The text was updated successfully, but these errors were encountered: