JUnit version 5.4.0 released on February 7, 2019 with a few important bug fixes, deprecations, features, and improvements. Since the release of JUnit 5, the popular Java testing framework has entered the next generation. The new version is programmer-friendly and was deemed to have “the potential to define testing on the JVM”.
Let’s take a look under the hood of this new update and see what improvements are in store for Java developers.
Newly added
Referring to the changelog, here’s what’s been added and improved:
The latest features include:
- New
junit-platform-reporting
artifact containing aLegacyXmlReportGeneratingListener
that generates XML reports using a format which is compatible with the de facto standard for JUnit 4 based test reports that was made popular by the Ant build system. - New
junit-platform-testkit
artifact containing a Test Kit API for testing the execution of aTestEngine
running on the JUnit Platform. - If a container or test fails, the root cause and suppressed exceptions are now included in the stack trace printed by the
ConsoleLauncher
. - The
ConsoleLauncher
now sanitizes user-provided display names before printing them to the console.- Common whitespace characters such as
t
,n
,x0B
,f
, andr
are replaced by a standard space character, and all other ISO control characters are emitted as a single dot (.
).
- Common whitespace characters such as
- New
ModifierSupport
class providing an API for extension and test engine authors to inspect modifiers of classes and members. AnnotationSupport
provides new methods for finding annotated fields and their values.ReflectionSupport
provides new methods for finding fields and reading a field’s value.- Exceptions reported due to failed reflective operations such as loading a class, reading a field’s value, or looking up a method by name now include the original exception as their cause to make it easier to debug underlying issues.
- The
Launcher
API now provides anexecute(TestPlan, TestExecutionListener…)
method that allows one to execute a previously discoveredTestPlan
. @RunWith(JUnitPlatform.class)
no longer executes test discovery twice.- Implementations of
HierarchicalTestEngine
may now add behavior that wraps around the invocation ofNode.before()
,Node.execute()
, andNode.after()
using the newNode.around()
hook.
That’s not all. See the changes made to Jupiter and Vintage in the changelog.
SEE ALSO: How well do you know your JUnit trivia?
Breaking changes
Take note of these deprecations and breaking changes to avoid a messy situation:
- The JUnit Platform Maven Surefire Provider (
junit-platform-surefire-provider
) has been discontinued and is no longer released as part of JUnit 5. Please use Maven Surefire’s native support for running tests on the JUnit Platform instead (requires Maven Surefire 2.22.0 or higher). TestPlan.add(TestIdentifier)
has always been considered internal and is now deprecated. While calls from third-party code will continue to work for the time being, IDEs and build tools should remove any such code as soon as possible
#JUnit 5.4 has been released!
Single dependency for Jupiter API, Engine, and Params
Test Kit for testing engines and extensions
Built-in TempDir extension
Display name generator API
Test execution order API
TestWatcher extension APIhttps://t.co/fgVCiphWpT— JUnit Team (@junitteam) February 7, 2019
The next generation
Do we have any newcomers to this testing framework?
Wondering what makes it different from other previous versions? The biggest difference, JUnit 5 is composed of different modules from three projects: JUnit Platform, JUnit Jupiter, and JUnit Vintage. (Fun fact: The name Jupiter was picked because it’s the fifth planet for JUnit 5.)
If you haven’t upgraded, now is a perfect time. The user guide is a great place to start on your journey. Frankly, we suggest that anyone who programs in Java should have it in their familiar toolkit.
Peruse through the sample applications on GitHub to get yourself familiarized. You will need JDK to build JUnit 5; all modules install with the Gradle Wrapper in a local Maven repo.
The post JUnit 5.4.0 release enhances the next generation Java testing framework appeared first on JAXenter.
Source : JAXenter