Writing unit tests is a part of good practice in software development. Maven's
test phase executes unit tests and generates the corresponding report. In this section, we will learn about writing a simple unit test for our utility class
ConversionUtil, and in the next section, we will see how to execute it and generate reports.
All the unit test classes should go under
src/test/java. Create the corresponding folder in the
MyDistance project. Once the folder is in place, right-click on it and navigate to New | Other.... Once the wizard window appears, type in
junit in the Filter section, select JUnit Test Case, and click on Next, as shown in the following screenshot:
In the window to follow, define the unit test class by filling ...