Developer Guide to JUnit5 Introduction & Setup in Maven

Backend Pro
0

 

Introduction

JUnit is the most popular unit-testing framework in Java programming language. The latest version of JUnit is JUnit 5. 

Unlike the older versions of JUnit, JUnit 5 is composed of several different modules. 
JUnit5 = JUnit Platform + JUnit Jupiter + JUnit Vintage
JUnit5 requires Java 8 (or higher) at runtime.  

JUnit Platform provides the foundation for launching the testing frameworks on the JVM. Provides the interface between JUnit & programming clients (Build tools, IDEs, 3rd party test libraries). 

JUnit Jupiter is required for writing tests & extensions in JUnit5. Provides a TestEngine for running jupiter based tests on the platform

JUnit Vintage provides a TestEngine for running JUnit3 & JUnit4 based tests on the platform. 

Architecture of JUnit 5

Referred from: https://developer.ibm.com/tutorials/j-introducing-junit5-part1-jupiter-api/

 Setup in Maven

Following dependencies are required for the JUnit5 integration. 

https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>        
https://mvnrepository.com/artifact/org.junit.platform/junit-platform-runner
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>1.8.2</version>
<scope>test</scope>
</dependency>        

These two dependencies are enough to write the JUnit test cases and run. 

The complete pom.xml can be found here. pom.xml

Check out the GitHub project at The Backend Pro

Post a Comment

0Comments
Post a Comment (0)