Date of Release: April 23, 2024
Scope:
-
Numerous bug fixes and enhancements regarding field and method search algorithms
-
@FieldSource
annotation for use with@ParameterizedTest
methods -
@AutoClose
annotation to automatically close field resources in tests -
ConversionSupport
utility for converting from a string to a supported target type -
Various documentation improvements
For a complete list of all closed issues and pull requests for this release, consult the 5.11.0-M1 milestone page in the JUnit repository on GitHub.
For assistance with upgrading, please consult the Upgrading to JUnit 5.11 page in the Wiki.
-
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. See the new Field and Method Search Semantics section of the User Guide for details.
-
ReflectionSupport.findFields(…)
now returns a distinct set of fields. -
Fixed parsing of recursive jar URIs which allows the JUnit Platform Launcher to be used inside Spring Boot executable jars for Spring Boot 3.2 and later.
-
The
junit-platform-suite-engine
now includes configuration provided via@ConfigurationParameter
when selecting tests byUniqueId
. -
In order to support using
@EnabledInNativeImage
on test classes,UniqueIdTrackingListener
now tracks descendants of skipped test containers.
-
As mentioned in the Bug Fixes section above, 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. The changes in the search algorithms may, however, result in breaking changes for some use cases. In light of that, it is possible to revert to the previous "legacy semantics". See the new Field and Method Search Semantics section of the User Guide for details.
-
New
ConversionSupport
utility injunit-platform-commons
which exposes the conversion logic that was previously private to JUnit Jupiter’s@ParameterizedTest
infrastructure — for use in third-party extensions and test engines. -
Error messages for type mismatches in
NamespacedHierarchicalStore
now include the actual type and value in addition to the required type. -
Updated
open-test-reporting
dependency to0.1.0-M2
.
-
Due to changes in the JUnit Platform regarding field and method search algorithms (see Bug Fixes above), numerous bugs have been addressed within JUnit Jupiter, including but not limited to the following.
-
Two
@TempDir
fields with the same name in a superclass and subclass will now both be injected. -
Two
@Test
methods with the same signature in a superclass and subclass will now both be invoked, as long as the@Test
method in the subclass does not override the@Test
method in the superclass, which can occur if the superclass method isprivate
or if the superclass method is package-private and resides in a different package than the subclass.-
The same applies to other types of test methods (
@TestFactory
,@ParameterizedTest
, etc.) as well as lifecycle methods (@BeforeAll
,@AfterAll
,@BeforeEach
, and@AfterEach
).
-
-
-
Kotlin support now depends on Kotlin API and language version 1.6; whereas, it previously depended on version 1.3.
-
New
@FieldSource
annotation for use with@ParameterizedTest
methods which allows you to source arguments from a local field or an external field referenced by fully qualified field name. This feature is similar to the existing@MethodSource
feature. See the User Guide for details. -
New
@AutoClose
annotation that can be applied to fields within tests to automatically close the annotated resource after test execution. See the User Guide for details. -
@TempDir
now suppressesNoSuchFileException
when attempting to delete files that may have been already deleted by another thread or process. -
JAVA_23
has been added to theJRE
enum for use with JRE-based execution conditions. -
New Exception Handling documentation in the User Guide.
-
Improved documentation for Assumptions in the User Guide.
-
Improved Javadoc for
assertThrows()
andassertThrowsExactly()
to make it clear that the supplied message is not the expected message of the thrown exception. -
Improved documentation for semantics of a disabled test regarding class-level lifecycle methods and callbacks.