Skip to content

Upgrading to JUnit 5.11

Sam Brannen edited this page Apr 21, 2024 · 4 revisions

This page provides guidance on upgrading to JUnit 5.11.

Field and method search algorithms now adhere to standard Java semantics regarding whether a given field or method is visible or overridden according to the rules of the Java language.

This addresses several bugs and results in the following changes in behavior.

  • Fields no longer hide fields from super types.
    • This applies to non-static as well as static fields (@TempDir, @RegisterExtension, etc.).
  • Methods no longer hide methods from super types unless a given method literally overrides the other method.
    • This applies to non-static as well as static methods (@BeforeAll, @BeforeEach, @Test, etc.).
  • Extensions and TestEngines may have to revise their search algorithms for fields and methods.
    • See case study in issue #3774 for an example.

Although the JUnit team recommends the use of the standard search semantics, developers may optionally revert to the legacy semantics via the junit.platform.reflection.search.useLegacySemantics JVM system property.

See the new Field and Method Search Semantics section of the User Guide for details.