Free tools Windows power users keep installed
One-click scans. No signup required.
JUnit 5 is the modern JUnit testing framework for Java projects, made up of the JUnit Platform, JUnit Jupiter, and JUnit Vintage. If you are writing new tests, start with Jupiter: add a method annotated with @Test and use an assertion to check the expected result.
What is JUnit 5?
JUnit 5 is a collection of components for testing Java applications. Its three parts have distinct roles, as explained in the JUnit 5.14.4 User Guide:
- JUnit Platform provides the foundation for launching JVM test frameworks. It includes the TestEngine API and a Console Launcher.
- JUnit Jupiter provides the programming and extension models for writing JUnit tests. Its engine runs Jupiter tests on the Platform.
- JUnit Vintage runs JUnit 3 and JUnit 4 tests on the Platform.
For a new test, Jupiter is the part you will use directly. The Platform is the execution foundation beneath it, while Vintage is useful when a project still has older JUnit tests.
What do you need before you start?
The JUnit 5.14.4 guide specifies Java 8 or higher at runtime. It also says JUnit can test code compiled with earlier JDK versions, so an application targeting an older Java release can be tested on a newer runtime.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problems#1 Best Overall
Use the setup guidance for the build tool and language your project already uses. JUnit provides starter projects and support information for Gradle with Java, Kotlin, or Groovy, as well as Maven and Ant. The guide’s build support and starter-project links are a safer starting point than copying a dependency snippet from an older tutorial, because dependency coordinates and integration details can vary by release.
JUnit Platform support is listed for IntelliJ IDEA, Eclipse, NetBeans, and Visual Studio Code. Pick the IDE and build tool already used by the project, and make sure they are configured for the same JUnit version.
Rank #2
How do you write your first JUnit 5 test?
A minimal Jupiter test marks a method with @Test, runs the behavior being checked, and uses an assertion to compare the actual result with the expected one. The official guide’s introductory Writing Tests example tests a calculator’s addition operation:
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
class CalculatorTests {
@Test
void addsTwoNumbers() {
Calculator calculator = new Calculator();
assertEquals(2, calculator.add(1, 1));
}
}
Here, @Test identifies the method as a Jupiter test, and assertEquals checks whether the calculator’s result matches the expected value. The example assumes that a Calculator class with an add method exists in the project; the test itself is the part that verifies its behavior.
Recommended Free Tools
Rank #3
How do you add JUnit 5 to a project?
- Identify the project’s build tool and language. Check whether it uses Maven, Gradle, or Ant and, for Gradle, whether the project is written in Java, Kotlin, or Groovy.
- Choose the matching JUnit starter or build-support instructions. Use the official JUnit 5.14.4 guide and its dependency metadata rather than assuming an older tutorial’s coordinates are still appropriate.
- Configure the IDE and build consistently. The guide lists integrations for IntelliJ IDEA, Eclipse, NetBeans, and Visual Studio Code, and support for Gradle, Maven, and Ant. Follow the instructions for the tools already in use and select the same JUnit version in each place.
- Run the test using the project’s normal workflow. Confirm that the build or IDE discovers the method annotated with
@Testand reports the assertion result.
When should you use JUnit Vintage?
Use Vintage when a project needs to run existing JUnit 3 or JUnit 4 tests on the JUnit Platform, including alongside new Jupiter tests during a migration. For JUnit 4 tests, the JUnit 5.14.4 guide specifies JUnit 4.12 or later on the class path or module path.
Vintage is not required just to write a new JUnit 5 test. Start new tests with Jupiter; add Vintage only if the project’s legacy tests need it to continue running on the Platform.
Quick Recap
Best Value
Rank #4
Which JUnit setup should a beginner choose?
| What you are deciding | Practical choice |
|---|---|
| Test API for new tests | JUnit Jupiter |
| Running JUnit 3 or JUnit 4 tests on the Platform | JUnit Vintage; for JUnit 4, the guide specifies version 4.12 or later on the class path or module path |
| Build tool | Use the official starter or support instructions for the project’s existing Gradle, Maven, or Ant setup |
| IDE | Use the listed Platform integration for the IDE already used by the project: IntelliJ IDEA, Eclipse, NetBeans, or Visual Studio Code |
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

