JUnit 5.5 arrives with several tweaks and enhancements
The latest version of JUnit 5 may seem like a small release but, in fact, it brings several new enhancements that make JUnit 5.5 an important release. Let’s have a quick look at what’s new.
The JUnit team is keeping up with their fast release cycle and the bring us the next version of JUnit 5.
The 5.5 release, even though it doesn’t bring any big new features, it does bring several tweaks and enhancements that make it an important release.
Let’s have a look at some of the highlights in JUnit 5.5.
What’s new in JUnit 5.5?
@RegisterExtension updates – There are several constraints around how @RegisterExtension can be used. Now, violating these constraints will cause an exception to be thrown, whereas previously fields that violated these constraints would be silently ignored. What’s more, until now, the declared field of @RegisterExtension must also implement an Extension interface. The JUnit team relaxed this constraint that only the assigned value of the field must implement Extension.
TestExecutionListener updates – When a TestExecutionListener throws an exception, the stacktrace is instead printed to the console at the WARN level. This allows the test suite execution to continue, but for the information about an error occurring not being lost, and also being clearly indicated.
MethodOrder updates – If a seed isn’t supplied via the junit.jupiter.execution.order.random.seedproperty, JUnit will generate a seed for you. Now, when this happens JUnit will also print log statement displaying the seed value used. This allows a test run to be recreated if a problem was discovered.
Execute classes in parallel – There are further improvements to the support of parallel test execution. More specifically:
junit.jupiter.execution.parallel.mode.classes.defaulthas been added, that allows support for defining how parallel test execution should interact at the class level
- There are two default values accepted
CONCURRENT, like with
junit.jupiter.execution.parallel.mode.classes.defaultwill default to the value that
junit.jupiter.execution.parallel.mode.defaultis set to, which is
Deprecation of enableIf/disabledIf (currently slated to be removed in 5.6) – Ultimately, this method provided little benefit overwriting an implementation of DisabledCondition, while having the drawbacks of creating a maintenance headache as the script would have to be copy-and-pasted if it was to be reused and also being slower to execute.
As mentioned earlier, this release brings a big list of changes, so please head over to the official release notes to see all the new enhancements.