Getting started with TestNG in Eclipse

In this blogpost, we will see how to configure how to a TestNG project in Eclipse IDE, and run a simple TestNG test case.

If you have not installed TestNG plugin in Eclipse IDE, visit Installation of TestNG in Eclipse IDE.

Step 1 : Create a Java project in Eclipse

Open Eclipse IDE.

Go to File -> New -> Java Project, and finish the process by giving project name and selecting JRE version .

For more information on this, visit this link.

Step 2 : Add TestNG library to build path of the project

Once after creating a Java project, we need to add the TestNG library to the build path of the project in order to utilize TestNG capabilities.

In order to add the library to build path, follow below steps

Right click on the project -> Build Path -> Configure build Path


After clicking on the Configure Build Path button, a dialog box for configuring project properties will be prompted. Click on Add Library button from the dialog box.



After clicking Add Library button, the wizard for adding library will be prompted, select TestNG from the list, click Next/ Finish button.


Once after clicking Next/ Finish button, TestNG would have been added in the Libraries, and you would be able to see it in Project Explorer, as shown below.


Step 3 : Create a TestNG class

Go to src folder of the Eclipse project, and follow the below steps.

Right click on src folder -> New -> Other -> TestNG class

You will be able to see a window as shown below. Click Next to continue.

Eclipse provides the options to  customize out TestNG class during creation. Here, we can select the annotations as per our needs, and click Finish.



On clicking Finish, the test class will be created with all the selected annotations methods in the previous step.

Step 4 : Run TestNG class in Eclipse

Now, it is time to run the test class created in previous step. Follow below series of steps to run the TestNG class.

Right click on TestNG class -> Run As -> TestNG Test


You will be able to see result of the run as below.


That is all from this blogpost. Hope it helps you!

Cheers 🙂



#create-a-testng-project-in-eclipse, #getting-started-with-testng