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.
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.
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.
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.
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.
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.
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]
I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…
Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…
Once we learn how to deploy an Ubuntu server, how to manage users, and how…
Key-takeaways: Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…
While developing a web application, or setting dynamic pages and meta tags we need to deal with…
Software architecture is one of the most discussed topics in the software industry today, and…