Date of Release: ❓
Scope: Fifth milestone release of JUnit 5 with a focus on dynamic containers, test instance lifecycle management, and minor API changes.
Warning
|
This is a milestone release and contains breaking changes. Please refer to the instructions above to use this version in a version of IntelliJ IDEA that bundles an older milestone release. |
For a complete list of all closed issues and pull requests for this release, consult the 5.0 M5 milestone page in the JUnit repository on GitHub.
-
All published JAR artifacts now contain an
Automatic-Module-Name
manifest attribute whose value is used as the name of the automatic module defined by that JAR file when it is placed on the Java 9 module path.
JAR file | Automatic-Module-Name |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
MethodSelector.getMethodParameterTypes()
no longer returnsnull
for parameter types if the selector is created viaDiscoverySelectors
without explicit parameter types. Specifically, if parameter types are not supplied and cannot be deduced, an empty string will be returned. Similarly, if parameter types are not explicitly supplied but can be deduced (e.g, via a suppliedMethod
reference),getMethodParameterTypes()
now returns a string containing the deduced parameter types. -
Instead of throwing a
NullPointerException
inDetails.TREE
mode, theConsoleLauncher
now prints the corresponding throwable’stoString()
representation as a fallback mechanism. -
DefaultLauncher
now catches and warns about exceptions generated by an engine in its discovery and execution phases. Other engines are processed normally. -
UniqueId.Segment
type and value strings are now partially URL encoded when the string representation of a unique ID is generated. All characters reserved by the activeUniqueIdFormat
syntax (e.g.,[
,:
,]
, and/
) are encoded. The default parser has also been updated to decode such encoded segments.
-
The deprecated
--hide-details
option of theConsoleLauncher
has been removed; use--details none
instead. -
The following previously deprecated methods have been removed.
-
junit-platform-engine
:Node.execute(EngineExecutionContext)
-
junit-platform-commons
:ReflectionUtils.findAllClassesInClasspathRoot(Path, Predicate, Predicate)
-
-
The
isLeaf()
method of theorg.junit.platform.engine.support.hierarchical.Node
interface has been removed. -
The default methods
pruneTree()
andhasTests()
have been removed fromTestDescriptor
.
-
When using
DiscoverySelectors
to select a method by its fully qualified method name or by providingmethodParameterTypes
as a comma-separated string, it is now possible to describe array parameter types using source code syntax such asint[]
for a primitive array andjava.lang.String[]
for an object array. Furthermore, it is now possible to describe multidimensional array types using either the JVM’s internal String representation (e.g.,[[[I
forint[][][]
,[[Ljava.lang.String;
forjava.lang.String[][]
, etc.) or source code syntax (e.g.,boolean[][][]
,java.lang.Double[][]
, etc.). -
The JUnit Platform Gradle plugin task
junitPlatformTest
can now be accessed directly during the configuration phase of a build. -
When a
TestEngine
is discovered via Java’sServiceLoader
mechanism, an attempt will now be made to determine the location from which the engine class was loaded, and if the location URL is available, it will be logged at configuration-level. -
The
mayRegisterTests()
method may be used to signal that aTestDescriptor
will register dynamic tests during execution. -
The
TestPlan
may now be queried for whether itcontainsTests()
. This is used by the Surefire provider to decide if a class is a test class that should be executed. -
The
ENGINE
enum constant was removed fromTestDescriptor.Type
. The default type of theEngineDescriptor
is nowTestDescriptor.Type.CONTAINER
.
-
@ParameterizedTest
arguments are no longer resolved for lifecycle methods and test class constructors to improve interoperability with regular and parameterized test methods with different parameter lists.
-
The migration support module is now named
junit-jupiter-migrationsupport
, without the dash-
betweenmigration
andsupport
. -
In order to ensure the composability of all supported extension APIs in JUnit Jupiter, several methods in existing APIs have been renamed.
-
See Extension API Migration for details.
-
-
The
arguments()
method in theArgumentsProvider
API in thejunit-jupiter-params
module has been renamed toprovideArguments()
. -
The
ObjectArrayArguments
class in thejunit-jupiter-params
module has been removed; the functionality for creating anArguments
instance is now available via theArguments.of(…)
static factory method. -
The
names
property of@MethodSource
has been renamed tovalue
. -
The
getTestInstance()
method in theTestExtensionContext
API has been moved to theExtensionContext
API. Furthermore, the signature has changed fromObject getTestInstance()
toOptional<Object> getTestInstance()
. -
The
getTestException()
method in theTestExtensionContext
API has been moved to theExtensionContext
API. -
The
TestExtensionContext
andContainerExtensionContext
interfaces have been removed, and allExtension
interfaces have been changed to useExtensionContext
instead.
Extension API | Old Name | New Name |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
The test instance lifecycle can now be switched from the default per-method mode to a new per-class mode via the new class-level
@TestInstance
annotation. This enables shared test instance state between test methods in a given test class as well as between non-static@BeforeAll
and@AfterAll
methods in the test class.-
See [writing-tests-test-instance-lifecycle] for details.
-
-
@BeforeAll
and@AfterAll
methods are no longer required to bestatic
if the test class is annotated with@TestInstance(Lifecycle.PER_CLASS)
. This enables the following new features.-
Declaration of
@BeforeAll
and@AfterAll
methods in@Nested
test classes. -
Declaration of
@BeforeAll
and@AfterAll
on interfacedefault
methods. -
Simplified declaration of
@BeforeAll
and@AfterAll
methods in test classes implemented with the Kotlin programming language.
-
-
Assertions.assertAll()
now tracks exceptions of any type (as opposed to only tracking exceptions of typeAssertionError
), unless the exception is a blacklisted exception in which case it will be immediately rethrown. -
If a
@ParameterizedTest
accepts an array as an argument, the string representation of the array will now be converted to a human readable format when generating the display name for invocations of the parameterized test. -
The
@EnumSource
now provides an enum constant selection mode that controls how the supplied names are interpreted. Supported modes includeINCLUDE
andEXCLUDE
as well as regular expression pattern matching modesMATCH_ALL
andMATCH_ANY
. -
Extensions may now share state across top-level test classes by using the
Store
of the newly introduced engine-levelExtensionContext
. -
Argument providing methods referenced using
@MethodSource
may now return instances ofDoubleStream
,IntStream
, andLongStream
directly. -
@TestFactory
now supports arbitrarily nested dynamic containers. SeeDynamicContainer
and abstract base classDynamicNode
for details.
-
The
VintageTestEngine
no longer filters out test classes declared as static member classes, since they are valid JUnit 4 test classes. -
The
VintageTestEngine
no longer attempts to execute abstract classes as test classes. Instead, a warning is now logged stating that such classes are excluded.