This document contains the change log for all JUnit 5 releases since 5.9 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.10.0-M1

Date of Release: May 13, 2023

Scope:

  • Promotion of various experimental APIs to stable

  • New LauncherInterceptor SPI

  • New testfeed details mode for ConsoleLauncher

  • New ConsoleLauncher subcommand for test discovery without execution

  • Dry-run mode for test execution

  • New NamespacedHierarchicalStore for use in third-party test engines

  • Stacktrace pruning to hide internal JUnit calls

  • New TempDirFactory SPI for customizing how temporary directories are created

  • Failure threshold for @RepeatedTest

  • New convenience base classes for implementing ArgumentsProvider and ArgumentConverter

  • Custom class loader support for class/method selectors, @MethodSource, @EnabledIf, and @DisabledIf

  • Improved configurability of parallel execution

  • Numerous bug fixes and minor improvements

For a complete list of all closed issues and pull requests for this release, consult the 5.10.0-M1 milestone page in the JUnit repository on GitHub.

JUnit Platform

Deprecations and Breaking Changes

  • Building native images with GraalVM now requires configuring the build arg --initialize-at-build-time=org.junit.platform.launcher.core.LauncherConfig and --initialize-at-build-time=org.junit.jupiter.engine.config.InstantiatingConfigurationParameterConverter.

New Features and Improvements

  • Promote various "experimental" APIs that have matured to "stable" including ModuleSelector, EngineDiscoveryListener, EngineDiscoveryRequestResolver, LauncherSession, LauncherSessionListener, parallel execution support classes, @Suite and related annotations, and others.

  • All utility methods in ReflectionSupport that return a List now have counterparts which return a Stream.

  • New tryToLoadClass(…​) variant in ReflectionSupport that accepts an explicit ClassLoader, allowing classes to be resolved with custom ClassLoader arrangements.

  • ReflectionSupport.findMethod(Class<?>, String, String) now uses the ClassLoader of the supplied Class to load parameter types instead of using the default ClassLoader. This allows parameter types to be resolved with custom ClassLoader arrangements (such as OSGi). Consequently, DiscoverySelectors.selectMethod(Class<?>, String, String) also now works properly with custom ClassLoader arrangements.

  • New overloaded constructors for ClassSelector, NestedClassSelector, MethodSelector, and NestedMethodSelector that take an explicit ClassLoader as a parameter, allowing selectors to select classes in custom ClassLoader arrangements like in OSGi.

  • For consistency with JUnit Jupiter lifecycle callbacks, listener method pairs for started/finished and opened/closed events are now invoked using "wrapping" semantics. This means that finished/closed event methods are invoked in reverse order compared to the corresponding started/opened event methods when multiple listeners are registered. This affects the following listener interfaces: TestExecutionListener, EngineExecutionListener, LauncherDiscoveryListener, and LauncherSessionListener.

  • New LauncherInterceptor SPI for intercepting the creation of instances of Launcher and LauncherSessionlistener as well as invocations of the discover and execute methods of the former. Please refer to the User Guide for details.

  • Support for limiting the max-pool-size-factor for parallel execution via a configuration parameter.

  • New testfeed details mode for ConsoleLauncher that prints test execution events as they occur in a concise format.

  • The existing functionality of the ConsoleLauncher has been split into two subcommands: execute for executing tests and engines for listing registered test engines.

  • A new discover subcommand has been added to the ConsoleLauncher to print the discovered tests for the specified details mode without executing them.

  • Improved error message for cyclic graphs detected during test discovery to be more actionable.

  • Extracted NamespacedHierarchicalStore from JUnit Jupiter engine for reuse by other test engines and their extensions.

  • New dry-run mode to simulate test execution without actually running tests. Please refer to the User Guide for details.

  • Stack traces produced by failing tests are now pruned of calls from the org.junit, java, and jdk packages by default. This feature can be disabled or configured to prune other calls via configurations parameters. Please refer to the User Guide for details.

JUnit Jupiter

Bug Fixes

  • The extensions supporting @MethodSource, @EnabledIf, and @DisabledIf now load classes by fully-qualified class name using the ClassLoader obtained from the test class when possible. This allows classes to be resolved with custom ClassLoader arrangements (such as OSGi).

  • When converting an argument for a @ParameterizedTest method from a fully-qualified class name (String) to a Class, the ClassLoader of the class in which the @ParameterizedTest method is declared is now used to resolve the Class instead of the default ClassLoader.

Deprecations and Breaking Changes

  • The dynamic parallel execution strategy now allows the thread pool to be saturated by default.

  • Implicit type conversion of boolean values like in @CsvSource is now stricter, only allowing values "true" or "false" (case-insensitive), in order to make accidental mistakes apparent, avoiding potential confusion.

New Features and Improvements

  • Promote various "experimental" APIs that have matured to "stable" including MethodOrderer, ClassOrderer, InvocationInterceptor, LifecycleMethodExecutionExceptionHandler, @TempDir, parallel execution annotations, and others.

  • @RepeatedTest can now be configured with a failure threshold which signifies the number of failures after which remaining repetitions will be automatically skipped. See the User Guide for details.

  • New ArgumentsAccessor.getInvocationIndex() method that supplies the index of a @ParameterizedTest invocation.

  • @EmptySource now supports additional types, including Collection and Map subtypes with a public no-arg constructor.

  • DisplayNameGenerator methods are now allowed to return null, in order to signal to fall back to the default display name generator.

  • New AnnotationBasedArgumentsProvider convenience base class which implements both ArgumentsProvider and AnnotationConsumer.

  • New AnnotationBasedArgumentConverter convenience base class which implements both ArgumentConverter and AnnotationConsumer.

  • New junit.jupiter.execution.parallel.config.dynamic.max-pool-size-factor configuration parameter to set the maximum pool size factor.

  • New junit.jupiter.execution.parallel.config.dynamic.saturate configuration parameter to disable pool saturation.

  • New TempDirFactory SPI for customizing how the @TempDir extension creates temporary directories. See the User Guide for details.

  • New junit.jupiter.tempdir.factory.default configuration parameter to set the default TempDirFactory for temporary directories.

  • If @MethodSource is used with a non-static factory method that should be static, the exception thrown now provides the user a meaningful explanation of how to address the problem.

JUnit Vintage

No changes.

5.9.3

Date of Release: April 26, 2023

Scope: Bug fixes and enhancements since 5.9.2

For a complete list of all closed issues and pull requests for this release, consult the 5.9.3 milestone page in the JUnit repository on GitHub.

JUnit Platform

No changes.

JUnit Jupiter

Bug Fixes

  • Parameter types for local @MethodSource factory method names are now validated. For example, @MethodSource("myFactory(example.NonexistentType)") will now result in an exception stating that example.NonexistentType cannot be resolved to a valid type.

  • The syntax for parameter types in local @MethodSource factory method names now supports canonical array names — for example, you may now specify int[] as in @MethodSource("myFactory(int[])") instead of the binary name [I as in @MethodSource("myFactory([I)") (which was already supported) and @MethodSource("myFactory(java.lang.String[])") instead of @MethodSource("myFactory([Ljava.lang.String;)").

  • The search algorithm used to find @MethodSource factory methods now applies consistent semantics for local qualified method names and fully-qualified method names for overloaded factory methods.

  • The {displayName} placeholder for @ParameterizedTest invocation names is no longer parsed using java.text.MessageFormat. Consequently, any text in the display name of the @ParameterizedTest method will be included unmodified in the invocation display name. For example, Kotlin method names and custom display names configured via @DisplayName can now contain apostrophes (') as well as text resembling MessageFormat elements such as {0} or {data}.

  • Exceptions thrown for files that cannot be deleted when cleaning up a temporary directory created via @TempDir now include the root cause.

  • Lifecycle methods are allowed to be declared as private again for backwards compatibility; however, using private visibility for lifecycle methods is strongly discouraged and will be disallowed in a future release.

New Features and Improvements

  • The search algorithm used to find @MethodSource factory methods now falls back to lenient search semantics when a factory method cannot be found by qualified name (without a parameter list) and also provides better diagnostics when a unique factory method cannot be found.

JUnit Vintage

No changes.

5.9.2

Date of Release: January 10, 2023

Scope: Bug fixes and enhancements since 5.9.1

For a complete list of all closed issues and pull requests for this release, consult the 5.9.2 milestone page in the JUnit repository on GitHub.

JUnit Platform

Bug Fixes

  • The Java 7 based constructor for ForkJoinPool is no longer accidentally used on Java 9 or higher when invalid ParallelExecutionConfiguration is provided. Instead, an exception is thrown for invalid configuration, thereby preventing invalid configuration from being silently ignored.

New Features and Improvements

  • New TestPlan.getTestIdentifier(UniqueId) and TestPlan.getChildren(UniqueId) methods to avoid parsing unique IDs unnecessarily during test execution.

  • Support for limiting the max-pool-size for parallel execution via a configuration parameter.

  • Suite discovery now ignores cycles encountered in a test suite and logs an informational message at CONFIG level instead of throwing an exception.

JUnit Jupiter

Bug Fixes

  • New @MethodSource syntax for explicitly selecting an overloaded local factory method without specifying its fully qualified name.

Deprecations and Breaking Changes

  • The fixed parallel execution strategy now allows the thread pool to be saturated by default.

New Features and Improvements

  • JAVA_21 has been added to the JRE enum for use with JRE-based execution conditions.

  • New junit.jupiter.execution.parallel.config.fixed.max-pool-size configuration parameter to set the maximum pool size.

  • New junit.jupiter.execution.parallel.config.fixed.saturate configuration parameter to disable pool saturation.

JUnit Vintage

Bug Fixes

  • Parameterized tests are now properly reported when used in combination with the Enclosed runner.

5.9.1

Date of Release: September 20, 2022

Scope:

  • New @EnabledInNativeImage and @DisabledInNativeImage annotations for testing in GraalVM native images.

  • Minor bug fixes and enhancements since 5.9.0

For a complete list of all closed issues and pull requests for this release, consult the 5.9.1 milestone page in the JUnit repository on GitHub.

JUnit Platform

Bug Fixes

  • ReflectionSupport.findMethods(…​) now returns a distinct set of methods.

  • Execution in GraalVM native images no longer requires --initialize-at-build-time for OpenTestReportGeneratingListener.

JUnit Jupiter

Bug Fixes

  • Headers provided via the value attribute in @CsvSource for a @ParameterizedTest are now properly parsed when the useHeadersInDisplayName attribute is set to true.

  • A @ParameterizedTest method configured with a @MethodSource annotation that references a factory method inherited from multiple interfaces no longer fails with an exception stating that multiple factory methods with the same name were found.

  • A @ParameterizedTest method configured with a @MethodSource annotation that references a factory method whose name is the same as other non-factory methods in the same class no longer fails with an exception stating that multiple factory methods with the same name were found.

  • Assertion failures thrown from methods with applied timeouts using ThreadMode.SEPARATE are now properly reported.

New Features and Improvements

  • New @EnabledInNativeImage and @DisabledInNativeImage annotations for enabling and disabling tests within a GraalVM native image.

JUnit Vintage

No changes.

5.9.0

Date of Release: July 26, 2022

Scope:

  • XML reports in the new Open Test Reporting format

  • Configurable cleanup mode for @TempDir

  • Configurable thread mode for @Timeout

  • Conditional execution based on OS architectures

  • New TestInstancePreConstructCallback extension API

  • Reusable parameter resolution for custom extension methods via ExecutableInvoker

  • Parameter injection for @MethodSource methods

  • New IterationSelector

  • Various improvements to ConsoleLauncher

  • Numerous bug fixes and minor improvements

For complete details consult the 5.9.0 Release Notes online.