IntelliJ IDEA Unit Test
We can run all unit tests inside the IntelliJ IDEA. IntelliJ IDEA has various unit testing frameworks like JUnit, TestNG and many more. In this section, we will understand how unit test work. Here, we are going to use JUnit 4:
Create Unit Test
Follow the steps given below to create Unit Test:
1. Create Projects
2. In src folder, create a Java class file and enter the following code.
3. Create a New Directory with name Test to perform Unit Testing.
4. Now our Project Structure will look like this.
5. Go to File->Project Structure->Module. A new window screen will open. Select the Test Directory in the Source menu to perform testing and then click Ok button.
6. Go to Navigate->Test. A Dialog box will appear.
7. Click Create New Test. A new window will open. Fill the details as given in the window. Click Ok Button.
8. New HelloWorldTest.java file will open. In this File, we have to type the following code.
9. Now Click Run. We can see the result generated in the bottom of the Editor.