JUnit 5 Release Notes (original) (raw)
This document contains the change log for all JUnit 5 releases since 5.11 GA.
Please refer to the User Guide for comprehensive reference documentation for programmers writing tests, extension authors, and engine authors as well as build tool and IDE vendors.
5.12.2
Date of Release: April 11, 2025
Scope: Bug fixes and enhancements since 5.12.1
For a complete list of all closed issues and pull requests for this release, consult the5.12.2 milestone page in the JUnit repository on GitHub.
JUnit Platform
No changes.
JUnit Jupiter
Bug Fixes
- Fix handling of
CleanupMode.ON_SUCCESS
with@TempDir
that caused no temporary directories (using that mode) to be deleted after the first failure even if the corresponding tests passed.
JUnit Vintage
No changes.
5.12.1
Date of Release: March 14, 2025
Scope: Bug fixes and enhancements since 5.12.0
For a complete list of all closed issues and pull requests for this release, consult the5.12.1 milestone page in the JUnit repository on GitHub.
JUnit Platform
Deprecations and Breaking Changes
- Set stable module name
org.junit.platform.console.standalone
for thejunit-platform-console-standalone
artifact, superseding the unstable name generated from the name of the JAR file when putting the artifact on the module path.
JUnit Jupiter
New Features and Improvements
- New
ExtensionContext.getEnclosingTestClasses()
method to help with migration away fromAnnotationSupport.findAnnotation(Class, Class, SearchOption)
(deprecated since 1.12.0) toAnnotationSupport.findAnnotation(Class, Class, List)
.
JUnit Vintage
No changes.
5.12.0
Date of Release: February 21, 2025
Scope:
- Output file attachments for tests and containers
- Improvements to the Open Test Reporting XML output
- Resource lock definition improvements
- Thread dumps on test timeouts
- Parameterized test validation improvements
- Filtering support for auto-registered extensions
- Kotlin contracts for assertions
- Configurable Jupiter extension context scope
- Enhancements to the
ConsoleLauncher
- Better support for GraalVM native image usage
- Improved discovery support for file-based test engines
- Customizable classpath scanning
- Parallel execution support in JUnit Vintage engine
- Numerous bug fixes and other enhancements
For a complete list of all closed issues and pull requests for this release, consult the 5.12.0-M1,5.12.0-RC1,5.12.0-RC2, and5.12.0 milestone pages in the JUnit repository on GitHub.
Overall Improvements
New Features and Improvements
- All affected JAR files now include
native-image.properties
files that contain the--initialize-at-build-time
option to avoid breakages in GraalVM projects when updating to newer versions of JUnit.
JUnit Platform
Deprecations and Breaking Changes
SearchOption
andAnnotationSupport.findAnnotation(Class, Class, SearchOption)
fromjunit-platform-commons
have been deprecated.
New Features and Improvements
ConsoleLauncher
now accepts multiple values for all--select
options.ConsoleLauncher
now supports a--select-unique-id
option to select containers and tests by unique ID.ConsoleLauncher
supports new--exclude-methodname
and--include-methodname
options to include or exclude methods based on fully qualified method names without parameters. For example,--exclude-methodname=^org\.example\..+#methodname
will exclude all methods calledmethodName
under packageorg.example
.- The
--select-file
and--select-resource
options for theConsoleLauncher
now support line and column numbers. - New
ReflectionSupport.makeAccessible(Field)
public utility method to be used by third parties instead of calling the internalReflectionUtils.makeAccessible(Field)
method directly. - The
ReflectionSupport.tryToLoadClass(…)
utility methods now support lookups for the"void"
pseudo-type, which indirectly supportsString
toClass
conversion for"void"
in parameterized tests in JUnit Jupiter. - New
addResourceContainerSelectorResolver()
method inEngineDiscoveryRequestResolver.Builder
which supports the discovery of class path resource based tests, analogous to the existingaddClassContainerSelectorResolver()
method. - New
getOutputDirectoryProvider()
method inEngineDiscoveryRequest
andTestPlan
to allow test engines to publish/attach files to containers and tests by callingEngineExecutionListener.fileEntryPublished(…)
. RegisteredTestExecutionListeners
can then access these files by overriding thefileEntryPublished(…)
method. - The following improvements have been made to theOpen Test ReportingXML output:
- Information about the Git repository, the current branch, the commit hash, and the current worktree status are now included in the XML report, if applicable.
- A section containing JUnit-specific metadata about each test/container to the HTML report is now written by open-test-reporting when added to the classpath/module path
- Information about published files is now included as attachments.
- If output capturing is enabled, the captured output written to
System.out
andSystem.err
is now included in the XML report.
- Output written to
System.out
andSystem.err
from non-test threads is now attributed to the most recent test or container that was started or has written output. - New public interface
ClasspathScanner
allowing third parties to provide a custom implementation for scanning the classpath for classes and resources. - New
AnnotationSupport.findAnnotation(Class, Class, List)
method to support searching for an annotation on an inner class and its runtime enclosing instance types. - New
TestDescriptor.orderChildren(UnaryOperator<List<TestDescriptor>> orderer)
method to order children in place
JUnit Jupiter
Bug Fixes
- Provide runtime enclosing types of
@Nested
test classes and contained test methods toDisplayNameGenerator
implementations. Prior to this change, such generators were only able to access the enclosing class in which@Nested
was declared, but they could not access the concrete runtime type of the enclosing instance. @DisplayNameGeneration
annotations are now discovered on the runtime enclosing types of@Nested
test classes instead of the compile-time enclosing class in which the@Nested
class was declared.- Fix handling of "junctions" on Windows during
@TempDir
cleanup: junctions will no longer be followed when deleting directories and broken junctions will be deleted.
Deprecations and Breaking Changes
- When injecting
TestInfo
into test class constructors, theTestInfo
now contains data for the test method for which the test class instance is being created, unless the test instance lifecycle is set toPER_CLASS
(in which case it continues to contain the data for the test class). If you require theTestInfo
of the test class, you can implement a@BeforeAll
lifecycle method and injectTestInfo
into that method. - When injecting
TestReporter
into test class constructors the published report entries are now associated with the test method rather than the test class, unless the test instance lifecycle is set toPER_CLASS
(in which case the published report entries will continue to be associated with the test class). If you want to publish report entries for the test class, you can implement a@BeforeAll
lifecycle method and injectTestReporter
into that method.
New Features and Improvements
- Kotlin contracts for Kotlin-specific assertion methods in
Assertions
. @TempDir
is now supported on test class constructors.- Shared resource locks may now be determined programmatically at runtime via the new
@ResourceLock#providers
attribute that accepts implementations ofResourceLocksProvider
. - Shared resource locks for direct child nodes may now be configured via the new
@ResourceLock(target = CHILDREN)
attribute. This may improve parallelization when a test class declares aREAD
lock, but only a few methods hold aREAD_WRITE
lock. @EnumSource
has newfrom
andto
attributes that support the selection of enum constants within the specified range.- In a
@ParameterizedTest
method, anull
value can now be supplied for Java Date/Time types such asLocalDate
if the newnullable
attribute in@JavaTimeConversionPattern
is set totrue
. - The new
@ParameterizedTest(allowZeroInvocations = true)
attribute allows to specify that the absence of invocations is expected in some cases and should not cause a test failure. - Parameterized tests now support argument count validation. If the
junit.jupiter.params.argumentCountValidation=strict
configuration parameter or the@ParameterizedTest(argumentCountValidation = STRICT)
attribute is set, any mismatch between the declared number of arguments and the number of arguments provided by the arguments source will result in an error. By default, it is still only an error if there are fewer arguments provided than declared. ArgumentsProvider
(declared via@ArgumentsSource
),ArgumentConverter
(declared via@ConvertWith
), andArgumentsAggregator
(declared via@AggregateWith
) implementations can now use constructor injection from registeredParameterResolver
extensions.TestTemplateInvocationContextProvider
extensions can now signal that they may potentially return zero invocation contexts by overriding the newmayReturnZeroTestTemplateInvocationContexts()
method.- Extensions that implement
TestInstancePreConstructCallback
,TestInstanceFactory
,TestInstancePostProcessor
,ParameterResolver
, orInvocationInterceptor
may override thegetTestInstantiationExtensionContextScope()
method to enable receiving a test-scopedExtensionContext
inExtension
methods called during test class instantiation. This behavior will become the default in future versions of JUnit. - The new
PreInterruptCallback
interface defines the API forExtensions
that wish to be called prior to invocations ofThread#interrupt()
by the@Timeout
extension. - When enabled via the
junit.jupiter.execution.timeout.threaddump.enabled
configuration parameter, an implementation ofPreInterruptCallback
is registered that writes a thread dump toSystem.out
prior to interrupting a test thread due to a timeout. TestReporter
now allows publishing files for a test method or test class which can be used to include them in test reports, such as the Open Test Reporting format.- Auto-registered extensions can now befiltered using include and exclude patterns that can be specified as configuration parameters.
JRE
-based conditions such as@EnabledOnJre
and@DisabledForJreRange
now support arbitrary Java versions. See theUser Guide for details.- The
@TempDir
extension now warns during cleanup when deleting symlinks that target locations outside the temporary directory to signal that the target file or directory is_not_ deleted, only the link to it.
JUnit Vintage
New Features and Improvements
- Added support for executing test classes and/or methods in parallel. Please refer to theUser Guide for more information.
5.11.4
Date of Release: December 16, 2024
Scope: Bug fixes and enhancements since 5.11.3
For a complete list of all closed issues and pull requests for this release, consult the5.11.4 milestone page in the JUnit repository on GitHub.
JUnit Platform
Bug Fixes
- Escape whitespace characters (such as line breaks) in XML attribute values (such as exception messages) in the legacy XML report generated by the Console Launcher. This change ensures the resulting XML files can be processed by downstream tools while preserving whitespace characters.
- Enable auto-flushing of output in the
ConsoleLauncher
to fix issues with buffering, in particular when using the--details=testfeed
option.
JUnit Jupiter
New Features and Improvements
JAVA_25
has been added to theJRE
enum for use with JRE-based execution conditions.
JUnit Vintage
No changes.
5.11.3
Date of Release: October 21, 2024
Scope: Bug fixes and enhancements since 5.11.2
For a complete list of all closed issues and pull requests for this release, consult the5.11.3 milestone page in the JUnit repository on GitHub.
JUnit Platform
Bug Fixes
- Fixed a regression in method search algorithms introduced in 5.11.0 when classes reside in the default package and using a Java 8 runtime.
JUnit Jupiter
Bug Fixes
- Extensions can once again be registered via multiple
@ExtendWith
meta-annotations on the same composed annotation on a field within a test class. @ExtendWith
annotations can now also be repeated when used directly on fields and parameters.- All
@…Source
annotations of parameterized tests can now also be repeated when used as meta annotations.
JUnit Vintage
No changes.
5.11.2
Date of Release: October 4, 2024
Scope: Bug fixes and enhancements since 5.11.1
For a complete list of all closed issues and pull requests for this release, consult the5.11.2 milestone page in the JUnit repository on GitHub.
JUnit Platform
Bug Fixes
- Fix regression in parallel execution that was introduced in 5.11.1 regarding global read-write locks. When such a lock was declared on descendants of top-level nodes in the test tree, such as Cucumber scenarios, test execution failed.
JUnit Jupiter
No changes.
JUnit Vintage
No changes.
5.11.1
Date of Release: September 25, 2024
Scope: Bug fixes and enhancements since 5.11.0
For a complete list of all closed issues and pull requests for this release, consult the5.11.1 milestone page in the JUnit repository on GitHub.
JUnit Platform
Bug Fixes
- Fix support for disabling ANSI colors on the console when the
NO_COLOR
environment variable is available. NamespacedHierarchicalStore
no longer throws an exception after it has been closed if the store is queried via one of theget(…)
orgetOrComputeIfAbsent(…)
methods; however, if agetOrComputeIfAbsent(…)
invocation results in the computation of a new value, an exception will still be thrown.- Fixed potential locking issue with
ExclusiveResource
in theHierarchicalTestExecutorService
, which could lead to deadlocks in certain scenarios.
New Features and Improvements
- Improve parallelism and reduce number of blocked threads used by
HierarchicalTestEngine
implementations when parallel execution is enabled and the global read-write lock is used.
JUnit Jupiter
Bug Fixes
TestWatcher
callback methods can once again access data in theExtensionContext.Store
.
New Features and Improvements
- Improve parallelism and reduce number of blocked threads in the presence of
@Isolated
tests when parallel execution is enabled
JUnit Vintage
No changes.
5.11.0
Date of Release: August 14, 2024
Scope:
@FieldSource
annotation for use with@ParameterizedTest
methods- Repeatable
@..Source
annotations for parameterized tests - Enhancements for authoring dynamic and parameterized tests
@AutoClose
annotation to automatically close field resources in testsConversionSupport
utility for converting from a string to a supported target type- Extensible syntax for specifying discovery selectors
@BeforeSuite
and@AfterSuite
annotations- Classpath resource scanning support for engines
- Numerous bug fixes and enhancements regarding field and method search algorithms