Search⌘ K
AI Features

Create and run JUnit 5 Test Case

Explore how to set up a Java class and create corresponding JUnit 5 test cases within a Maven project. This lesson guides you through writing a simple Calculator class, creating a test class with proper package structure, adding test methods with annotations, and running tests using Maven commands to verify functionality.

Create a Java class

After adding the required dependencies, let’s create a Java class. It will be our class under test.

Step 1 - Expand the junit5-maven-starter project. In order to create a new Java class, right-click on src/main/java traverse to New --> Class. Click on Class to add a new Java class.

Step 2 - New Java Class popup window will be opened.

Step 3 - Provide Package name of your choice.

Step 4 - Enter Name of class as, Calculator.

Step 5 - ...