Create-test-class-Intellij 3

Create test class Intellij – For any Java class unit testing is very important to make sure whatever business functionality is added into class is working properly or not. For those who came from Eclipse IDE and just started using IntelliJ for the first time and want to add unit test class please follow steps below:

Open the java class in editor below:

Create test class Intellij 1

Select the class name and press Alt+Enter to see list of available option as below:

Create test class Intellij 2

In the above option click on Create test IntelliJ will prompt you below with class method name. Select the method which you want to include into test class then click Ok:

Create test class Intellij 3

Intellij Idea provide another way to create test class is to highlight the class and place the cursor on the class name and select Navigate –> Test from the main menu, or select Go to –> Test from the shortcut menu, and click Create New Test as show in below picture:

Create test class Intellij 4

After clicking Test from Navigate drop-down you will see below window where it will show you to Create New Test..

After you click Create New Test you will see same pop-up window as earlier shown in below:

Follow the same steps and choose your method name whatever you want to include in your test class then click OK. Fianally you will see test class got created. As I am creating test class for file name: CalculateTax.java class so my class got crated below with test method:

JUNIT Intellij

For more information please visit Intellij

Leave a Reply

Your email address will not be published. Required fields are marked *