This document contains the change log for all JUnit 5 releases since 5.1 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-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
-
Full stacktrace is 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 (cf. User Guide). -
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 the Fork/Join Framework. -
Node
implementations may provide a set ofExclusiveResources
and anExecutionMode
to be used byForkJoinPoolHierarchicalTestExecutorService
.
-
-
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 were 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 factory methodsdynamicContainer(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 a complete list of all closed issues and pull requests for this release, consult the 5.2 M1, 5.2 RC1, and 5.2 GA milestone pages in the JUnit repository on GitHub.
JUnit Platform
Bug Fixes
-
Tag expressions containing spaces are now supported in the JUnit Platform Maven Surefire provider.
-
Duplicate
--config
keys supplied to theConsoleLauncher
are now reported properly. -
Exceptions thrown in
Node.after()
(in theHierarchicalTestEngine
infrastructure) no longer mask earlier exceptions.
New Features and Improvements
-
The JUnit Platform Surefire Provider (
junit-platform-surefire-provider
) now works with and requires Surefire2.21.0
which allows it to be used with Java 9 and Java 10. -
The default include pattern for filtering class names now matches test classes whose names either start with
Test
or end withTest
orTests
.-
This pattern is used by the
ConsoleLauncher
, the JUnit Platform Gradle Plugin, and theJUnitPlatform
runner.
-
JUnit Jupiter
Bug Fixes
-
Exceptions thrown by an
AfterAllCallback
no longer mask exceptions thrown at the class level when using the@TestInstance(PER_CLASS)
lifecycle mode.
New Features and Improvements
-
New
assertDoesNotThrow()
methods inAssertions
which assert that the execution of a given code block does not throw any kind of exception. -
New
fail()
method inAssertions
makes it possible to fail a test without an explicit failure message. -
Implicit support for widening primitive conversion for an argument supplied to a
@ParameterizedTest
.-
For example, a parameterized test annotated with
@ValueSource(ints = { 1, 2, 3 })
can be declared to accept an argument of typeint
,long
,float
, ordouble
.
-
-
@MethodSource
now supportsstatic
factory methods declared in external classes referenced by fully qualified method name. -
Support for aggregation of multiple
@ParameterizedTest
arguments into a single object.-
For details, see Argument Aggregation.
-
5.1.1
Date of Release: April 8, 2018
Scope: Bug fixes and minor improvements since the 5.1.0 release
For a complete list of all closed issues and pull requests for this release, consult the 5.1.1 milestone page in the JUnit repository on GitHub.
JUnit Jupiter
New Features and Improvements
-
The
ParameterContext
API used inParameterResolver
implementations now includes the following convenience methods for looking up annotations on parameters. Extension authors are strongly encouraged to use these methods instead of those provided in the corejava.lang.reflect.Parameter
API due to a bug injavac
on JDK versions prior to JDK 9 which causes lookups for annotations on parameters in inner class constructors to fail consistently — for example, when resolving a parameter for a@Nested
test class constructor.-
boolean isAnnotated(Class<? extends Annotation> annotationType)
-
Optional<A> findAnnotation(Class<A> annotationType)
-
List<A> findRepeatableAnnotations(Class<A> annotationType)
-
5.1.0
Date of Release: February 18, 2018
Scope:
-
Discovering tests in Java 9 modules
-
Improved Kotlin support
-
Tag expression language for filtering tests to be executed
-
Annotation-based conditional test execution with support for environment variables, system properties, operating systems, JRE versions, and dynamic scripts
-
Various improvements for writing parameterized tests
-
Refinements to the
ExtensionContext
API -
Support for re-running individual dynamic tests, parameterized tests, and test template invocations within an IDE
For complete details consult the 5.1.0 Release Notes online.