JUnit 6.0 adds Java 17 & Kotlin 2.2, unified versioning & JSpecify nullability annotations

JUnit 6.0 adds Java 17 & Kotlin 2.2, unified versioning & JSpecify nullability annotations

JUnit 6.0 has been released as a major update to the popular Java and Java Virtual Machine (JVM) testing framework. This version now requires Java 17 and Kotlin 2.2 as the minimum language levels, which may impact developers maintaining projects on older platforms. All platform, Jupiter, and Vintage artifacts now share the same version number, making dependency management easier for users.

Building on these core changes, all JUnit modules have adopted JSpecify nullability annotations, clarifying which method parameters and return types can hold null values. The release streamlines existing modules by removing both the junit-platform-jfr module and its Java Flight Recorder (JFR) events — these features are now provided by junit-platform-launcher — and also eliminates the junit-platform-runner module for JUnit 4 users.

Addressing test organization, the update enforces deterministic but intentionally nonobvious ordering of @Nested classes, extends @TestMethodOrder inheritance to @Nested inner classes, and introduces MethodOrderer.Default and ClassOrderer.Default types to reset order when needed. CSV input handling in @CsvSource and @CsvFileSource has moved from univocity-parsers to FastCSV, which improves error reporting and handling of malformed entries.

Additional enhancements include support for Kotlin suspend functions as test methods, a --fail-fast mode for ConsoleLauncher, test execution cancellation via CancellationToken, the removal of deprecated APIs, and much more, as detailed in the release notes.

by Paul

cz
Arthagam
city_zen found this interesting
JUnit iconJUnit
  15
  • ...

JUnit is a unit testing framework specifically designed for the Java programming language. It plays a significant role in test-driven development, allowing developers to write and run repeatable automated tests. JUnit is part of the xUnit family of frameworks, which originated with SUnit. It is widely used for ensuring code reliability and functionality through rigorous testing practices.

No comments so far, maybe you want to be first?
Gu