JUnit 5.3 arrives with lots of updates in tow

A few months after the 5.2 release, one of our most favorite testing frameworks is here with another update, packed with a long list of new features, bug fixes, and improvements. Let’s take a closer look!
The JUnit team released version 5.3 earlier this month and 5.3.1 just yesterday. It may look like a minor update but trust me, it brings a lot of good stuff with it!
Let’s jump into the long list of new features, bug fixes, and improvements!
All the shiny new things
We have a long list of new features and breaking changes for JUnit Platform, Jupiter and Vintage.
JUnit Platform
- The
junit-platform-gradle-plugin
has been discontinued and is no longer released as part of JUnit 5. - 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. - The JUnit Platform
Launcher
now enforces that onlyTestEngine
implementations published by the JUnit Team may use thejunit-
prefix for theirTestEngine
IDs. - 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.
The list of new features and improvements is truly extensive but just to give you a small taste:
- Reusable support for parallel test execution for test engines that extend
HierarchicalTestEngine
. - Experimental support for capturing output printed to
System.out
andSystem.err
during test execution. - The
ConsoleLauncher
now uses the picocli library under the hood to parse the command line and generate usage help.
You can check the official release notes for the full list.
JUnit Jupiter
- In order to revert the aforementioned breaking change, variants of
assertThrows()
introduced in JUnit 5.3.0 that acceptThrowingSupplier
arguments have been removed. @Nested
test classes can no longer overrideTestInstanceFactory
extensions registered on an enclosing class. This aligns with the behavior forTestInstanceFactory
extensions registered within a conventional test class hierarchy.
SEE ALSO: Big changes to JUnit 5.2
Once again, the list of new features and improvements is endless so I will refer you to the release notes. But just to give you an idea of what to expect:
- New support for supplying a custom test source
URI
when creating a dynamic container or test. - 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
{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.
JUnit Vintage
- The
VintageTestEngine
now uses the simple name of a test class as the display name instead of the fully qualified class name. This aligns with the behavior of theJupiterTestEngine
.
You can have a look at the changelog for the extensive list of bug fixes and visit the user guide for comprehensive reference documentation for programmers writing tests, extension authors, and engine authors as well as build tool and IDE vendors.
gipugwe