News

JUnit 5.4 released with an aggregate artifact for reducing your Maven and Gradle files

2 min read

Last month, the team behind the JUnit framework announced the release of JUnit 5.4. This release allows ordering extensions and test case execution provides an aggregate artifact for slimming your Maven and Gradle files, and more.

Some new features in JUnit 5.4

Ordering test case execution

JUnit 5.4 allows you to explicitly define a text execution order. To enable tests ordering, you need to annotate the class with the ‘@TestMethodOrder’ extension and also mention the ordering type of either Alphanumeric, OrderAnnotation, or Random. Alphanumeric orders the test execution based on the method name of the test case. For a custom defined execution, you can use the OrderAnnotation order type. To order test cases pseudo-randomly, you can use the Random order type.

Extension ordering

With this release, you can not only order test case execution but also order how programmatically register extensions are executed. These extensions are registered with @RegisterExtension. You can use this feature in cases where the setup/teardown behavior of a test is complex and has separate domains. For instance, when you are testing the behavior of how a cache and database are used.

Aggregate artifact

A large number of dependencies were required when using JUnit 5. With this release, the team has changed this by providing the ‘junit-jupiter’ aggregate artifact. The ‘junit-jupiter’ artifact includes ‘junit-jupiter-api’ and ‘junit-jupiter-params’. This artifact collectively covers most of the dependencies we will need when using JUnit 5. It will also help in reducing the size of Maven and Gradle files of projects using JUnit 5.

TempDir

In JUnit 5.4, the team has added @TempDir as a native feature of the JUnit framework, which was originally a part of the JUnit-Pioneer third-party library. You can use the @TempDir extension for handling the creation and cleanup of temporary files.

TestKit

With TestKit, you can perform a meta-analysis on a test suite. It allows you to check the number of executed tests, passed tests, failed tests, skipped tests, as well as a few other behaviors.

To read the full list of updates in JUnit 5.4, check out the official announcement.

Read Next

Apache NetBeans IDE 10.0 released with support for JDK 11, JUnit 5 and more!

JUnit 5.3 brings console output capture, assertThrow enhancements and parallel test execution

Unit testing with Java frameworks: JUnit and TestNG [Tutorial]

 

Bhagyashree R

Share
Published by
Bhagyashree R

Recent Posts

Top life hacks for prepping for your IT certification exam

I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…

3 years ago

Learn Transformers for Natural Language Processing with Denis Rothman

Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…

3 years ago

Learning Essential Linux Commands for Navigating the Shell Effectively

Once we learn how to deploy an Ubuntu server, how to manage users, and how…

3 years ago

Clean Coding in Python with Mariano Anaya

Key-takeaways:   Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…

3 years ago

Exploring Forms in Angular – types, benefits and differences   

While developing a web application, or setting dynamic pages and meta tags we need to deal with…

3 years ago

Gain Practical Expertise with the Latest Edition of Software Architecture with C# 9 and .NET 5

Software architecture is one of the most discussed topics in the software industry today, and…

3 years ago