JUnit 5 Maven Dependency

By | December 3, 2019

In this post, we will learn how to configure Maven Dependency for JUnit 5 and how to use them to create and execute JUnit Tests

Note: JUnit 5 requires minimum Java 8 at runtime.

To execute JUnit 5 tests using maven we will need a minimum of two dependencies.

1.    JUnit Jupiter Engine Dependency

junit-jupiter-engine has internally dependency on  junit-platform-engine and junit-jupiter-api so if you add junit-jupiter-engine dependency then it will bring all three dependencies into class path.


 Junit 5 jupiter engine dependency tree

junit-jupiter-api has all JUnit annotations to write tests and extensions and junit-platform-engine has test engine implementation which is required at runtime to run the tests.

2.    JUnit Platform Runner Dependency

We usually need junit-platform-runner for executing JUnit tests and test suites on the JUnit Platform environment.

As junit-platform-runner is internally dependents on junit-platform-launcher  and junit-platform-suite-api  so if you add junit-platform-runner  dependency then it will bring all three dependencies into class path.


Junit 5 platform runner dependency tree

Complete JUnit 5 Maven Project Example

Project structure











Utility Class for that we have to write JUnit Test:

 JUnit Test class


Right-click on JUnit Class and choose Run As -> JUnit Test

The output of above JUnit Project

You may also like:
Junit 5 Architecture
JUnit 5 Annotations

That’s all about JUnit 5 Maven Dependency
If you have any feedback or suggestion please feel free to drop in below comment box.

Leave a Reply

Your email address will not be published. Required fields are marked *