JUnit 5 Introduction

This lesson introduces JUnit 5, one of the most popular and powerful testing framework for Java.

Introduction

Junit was developed by Kent Beck and Erich Gamma. Its first version was released in 1997. It became one of the most popular testing frameworks in the Java community due to its ease of use. It is a lightweight testing framework which allowed Java developers to write unit test cases in Java language. The recent version released is 5.3.2, which is termed as Junit 5.

What is Junit 5?

Junit 5 is a powerful and popular Java testing framework. It is composed of many different modules. These different modules are parts of three sub-projects as follows:-

  • Junit Platform
  • Junit Jupiter
  • Junit Vintage

In short it is represented as,


JUnit 5 = JUnit Platform + JUnit Jupiter + JUnit Vintage


The above three projects are core to Junit 5. The architecture of JUnit 5 mostly comprises of these 3 components/sub-projects. In the next few lessons, we will take a look at more details of above three sub-projects.

Course Interactivity

Interactive practice environments are embedded in every lesson to give you a hands-on learning experience.

Let’s look into an interactive demo below. you don’t need to understand this for now but here’s how we are going to learn using Educative. Just run below JUnit 5 code widget and have a look at output without any setup or download. You can also edit code and run to understand more.

package io.educative.junit5;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
class HelloWorldTest {
@Test
void checkHelloMsg() {
assertEquals("Hello World", "Hello World");
}
}
Introduction to JUnit