This document contains the change log for all JUnit 5 releases since 5.2 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.3.0-RC1
Date of Release: August 13, 2018
Scope: Finishing touches on parallel test execution and output capturing, bug fixes and miscellaneous usability improvements.
For a complete list of all closed issues and pull requests for this release, consult the 5.3 RC1 milestone page in the JUnit repository on GitHub.
JUnit Platform
Bug Fixes
-
All
DiscoverySelector
implementations (e.g.,PackageSelector
,ClassSelector
,MethodSelector
, etc.) now implementequals()
andhashCode()
for proper behavior when stored in collections. -
ClassSource
has been revised so thatequals()
andhashCode()
are now properly based on the required class name instead of the optionalClass
reference. In addition, the non-blank precondition for a class name is now enforced.
Deprecations
-
The JUnit Platform Surefire Provider (
junit-platform-surefire-provider
) is now deprecated in favor of the native support for the JUnit Platform provided by Maven Surefire 2.22.0 and later versions.
New Features and Improvements
-
New
LauncherConfig
and associated builder for configuring theLauncherFactory
. Specifically, auto-registration of test engines and test execution listeners can now be disabled, and additional engines and listeners can be registered programmatically. -
New
MethodSource.from(Class, Method)
static factory method for creating aMethodSource
from a specific class and method. This method should be used in favor ofMethodSource.from(Method)
when the test method is inherited from a superclass or present as an interfacedefault
method. -
A
ClasspathResourceSource
can now be created from aURI
via the newfrom(URI)
static factory method if theURI
uses theclasspath
scheme. -
If the new experimental feature is enabled, captured output to
System.out
andSystem.err
is now written to the dedicatedsystem-out
andsystem-err
elements, respectively, in the XML report generated byConsoleLauncher
. -
The
ConsoleLauncher
now uses the picocli library under the hood to parse the command line and generate usage help. Users may now pass command line arguments via an argument file (@-file
) to the console launcher. Argument files allow users to work around system limitations on the length of a command line when creating a command line with lots of options or with long arguments for options. The usage help is now displayed using ANSI colors on supported platforms.
JUnit Jupiter
Bug Fixes
-
The
MethodSource
for an inherited@Test
method now correctly references the current test class instead of the class or interface in which the@Test
method is declared. This allows build tools such as Maven Surefire to properly include inherited@Test
methods when executing a single test class or specific test classes based on filters — for example, viamvn test -Dtest=SubclassTests
). -
Exceptions thrown in
@After
and@AfterAll
lifecycle methods now take precedence over violated assumptions (i.e.TestAbortedExceptions
) in test or prior lifecycle methods.
New Features and Improvements
-
Generation of a detailed failure message for a failed assertion no longer fails if the
toString()
implementation of an object supplied to the assertion throws an exception. Instead, the object with the brokentoString()
implementation will be referenced via a default String representation based on the object’s fully qualified class name and system hash code, separated by an@
symbol. -
Although it is highly discouraged, it is now possible to extend the
org.junit.jupiter.api.Assertions
andorg.junit.jupiter.api.Assumptions
classes for special use cases. -
New
publishEntry(String)
method inTestReporter
that makes it easier to publish a report entry based solely on a value without requiring that a key be specified (as is required by the existingpublishEntry()
variants). -
A custom test source
URI
for a dynamic container or dynamic test will now be registered as aClasspathResourceSource
if theURI
uses theclasspath
scheme. -
New
TestInstanceFactory
extension API that enables custom creation of test class instances.-
See Test Instance Factories in the User Guide for details.
-
-
ArgumentConverters
andArgumentsAggregators
registered using@ConvertWith
and@AggregateWith
, respectively, are now only instantiated once per@ParameterizedTest
instead of once for each invocation. -
Performance improvements for executing parameterized tests, particularly when the method declares more than a few parameters.
-
New
{displayName}
placeholder for thename
attribute in@ParameterizedTest
that allows developers to include the display name of the@ParameterizedTest
method in a custom display name for invocations of that parameterized test.-
This aligns with the existing
{displayName}
placeholder support for@RepeatedTest
.
-
-
Generation of the display name for a
@ParameterizedTest
no longer fails if thetoString()
implementation of an argument for the parameterized test throws an exception. Instead, the object with the brokentoString()
implementation will be referenced via a default String representation based on the object’s fully qualified class name and system hash code, separated by an@
symbol. -
New
getAs<Class>(index)
Kotlin extension method to makeArgumentsAccessor
friendlier to use from Kotlin. -
Tests in classes that use
Lifecycle.PER_CLASS
are now executed in the same thread by default when parallel execution is enabled.
JUnit Vintage
Bug Fixes
-
The
MethodSource
for an inherited@Test
method now correctly references the current test class instead of the class or interface in which the@Test
method is declared. This allows build tools such as Maven Surefire to properly include inherited@Test
methods when executing a single test class or specific test classes based on filters — for example, viamvn test -Dtest=SubclassTests
).
5.3.0-M1
Date of Release: June 24, 2018
Scope: Parallel test execution, output capturing, test sources for dynamic tests as well as various minor improvements and bug fixes.
For a complete list of all closed issues and pull requests for this release, consult the 5.3 M1 milestone page in the JUnit repository on GitHub.
JUnit Platform
Bug Fixes
-
The full stacktrace is now printed to the console when running the
ConsoleLauncher
in--details verbose
mode. -
ReflectionUtils.findNestedClasses()
andReflectionSupport.findNestedClasses()
no longer allow aNoClassDefFoundError
to propagate if a nested class or nested interface has an invalid class file. Instead, the error will now be swallowed and logged atWARNING
level.
Deprecations and Breaking Changes
-
The
junit-platform-gradle-plugin
has been discontinued and is no longer released as part of JUnit 5. Please use Gradle’s native support for running tests on the JUnit Platform (requires Gradle 4.6 or higher) instead. -
The
findAnnotation()
methods inAnnotationSupport
andAnnotationUtils
no longer cache annotation lookups. Note, however, that the algorithm remains otherwise unmodified and is therefore semantically identical to the previous behavior.
New Features and Improvements
-
Experimental support for capturing output printed to
System.out
andSystem.err
during test execution. This feature is disabled by default and can be enabled using a configuration parameter (see the User Guide for details). -
Reusable support for parallel test execution for test engines that extend
HierarchicalTestEngine
.-
HierarchicalTestEngine
implementations may now specify aHierarchicalTestExecutorService
. -
By default, a
SameThreadHierarchicalTestExecutorService
is used. -
Test engines may use
ForkJoinPoolHierarchicalTestExecutorService
to support parallel test execution based on Java’s Fork/Join framework. -
Node
implementations may provide a set ofExclusiveResources
and anExecutionMode
to be used byForkJoinPoolHierarchicalTestExecutorService
.
-
-
New
UriSource.from(URI)
static factory method that allows aTestSource
to be created from aURI
. If theURI
references a file or directory in the local filesystem, aFileSource
orDirectorySource
will be created; otherwise, an instance of the defaultUriSource
implementation will be created. -
New overloaded variant of
isAnnotated()
inAnnotationSupport
that acceptsOptional<? extends AnnotatedElement>
instead ofAnnotatedElement
. -
New
--fail-if-no-tests
command-line option for theConsoleLauncher
.-
When this option is enabled and no tests are discovered, the launcher will fail and exit with a status code of
2
.
-
JUnit Jupiter
Bug Fixes
-
When using
@TestInstance(Lifecycle.PER_CLASS)
semantics, registeredAfterAllCallback
extensions are no longer invoked if an exception is thrown by the test class constructor. Consequently,AfterAllCallback
extensions are now only invoked ifBeforeAllCallback
extensions are invoked. -
Test discovery no longer halts prematurely if a nested class or nested interface in a test class has an invalid class file.
-
Certain categories of errors encountered during the test discovery phase no longer cause JUnit Jupiter to prematurely abort the entire discovery process.
-
Such errors are now logged, thereby enabling JUnit Jupiter to discover and execute as many tests as possible while still informing the user of containers and tests that could not be properly discovered.
-
New Features and Improvements
-
Experimental support for parallel test execution. By default, tests are still executed sequentially; parallelism can be enabled using a configuration parameter (please refer to the User Guide for examples and configuration options).
-
New support for the IBM AIX operating system in
@EnabledOnOs
and@DisabledOnOs
. -
New
assertThrows
methods inAssertions
provide a more specific failure message if the supplied lambda expression or method reference returns a result instead of throwing an exception. -
New
arguments()
static factory method in theArguments
interface that serves as an alias forArguments.of()
.arguments()
is intended to be used viaimport static
. -
New
get<Class>(index)
Kotlin extension method to makeArgumentsAccessor
friendlier to use from Kotlin. -
New support for supplying a custom test source
URI
when creating a dynamic container or test.-
See the new factory methods
dynamicContainer(String, URI, …)
inDynamicContainer
anddynamicTest(String, URI, Executable)
inDynamicTest
for details.
-
5.2.0
Date of Release: April 29, 2018
Scope: JUnit BOM, support for Maven Surefire 2.21.0 allowing builds with Java 9 and
Java 10, argument aggregation and widening primitive conversion for arguments in
parameterized tests, external factory methods for @MethodSource
, as well as various
minor improvements and bug fixes.
For complete details consult the 5.2.0 Release Notes online.