-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
JUnit Java Baselines
JUnit 5 is developed using a trunk-based model: new features and bug fixes are happening at https://github.com/junit-team/junit5/commits/main/ (the tip) with only critical fixes are backported to older 5.x branches (tails).
All major JUnit releases are usable on the latest-and-greatest (read: tip) Java release, which is JDK 23.0.1 as of today. This is due to JUnit's authors strived to use only supported API of Java when implementing features. Combined with Java's excellent backward and forward compatibility users of JUnit seldom care about JUnit's Java base line version. For example, test code compiled with Java 5 and using JUnit 3 API can still be run on Java 24 Early Access without changing a thing.
So, when did the Java base line for JUnit change?
- JUnit 0 - 1997 - Java 1 -
extends TestCase
- Test method names must begin withtest
. - JUnit 3 - 2002 - Java ? - Merged with JUnit 4 by now.
- 3.8.2 released 2007
- JUnit 4 - 2006 - Java 5 -
@Test
- Test methods are annotated with@Test
.- 4.13.2 released 2021
- JUnit 5 - 2017 - Java 8 -
() -> {}
- Dynamic tests using Lambdas.- 5.11.3 released 2024
What's the main driver to upgrade JUnit to require a new Java base version?
A Java feature that impacts how users write tests:
There was no standalone/major feature introduced in Java 9 to 23 that would have changed how users write tests.
Will there be such a major feature in future?
Will there be an amount of accumulated "minor" features that would users want to use?
Some interesting Java features were either backported to Java 8 by OpenJDK or they blend-in naturally.
- JFR was backported
-
record
behave as normal classes
For a small subset of features JUnit 5 uses the multi-release JAR technique to support Java 9+ features:
- Java Modules - Java 9 - 1st class
module-info
support,--select-module
, and--scan-modules
- Console API - Java 17 - default charset retrieval
- Virtual Threads - Java 21 - WIP
JUnit 5 is built with JDK 21 using javac
's --release 8
option.
Self-tests can be written using Java 21 API.
Test authors are a the largest consumer group of JUnit API. Tool authors are another important group of JUnit's costumers.
Stability is key.