Site icon SumTips

How to Install TestNG in Eclipse IDE

TestNG comes as a plugin for Eclipse IDE. However, before we can start using it, TestNG plugin has to be installed and configured. There are three ways to install TestNG In Eclipse IDE:

  1. Install TestNG via Eclipse Marketplace
  2. Install TestNG as a Software via Repository
  3. Install TestNG via JAR files

We’ll be going through each method in this post. I am using Eclipse Oxygen.2 version on Windows 10 – if you are using any other version of Eclipse or Windows, the screen shots might appear different, but the basic installation steps remain the same.

Method 1: Install TestNG via Eclipse Marketplace

We’ll start off with the quickest and easiest method.

Step 1: Launch Eclipse IDE > Navigate to “Eclipse Marketplace..” under Help menu. Click on it.
Step 2: A new dialog, as seen below, should open up. In the “Find” field, enter “TestNG” and click on “GO.” You should now see “TestNG for Eclipse” listed with an “Install” button. Click on it to download and install the plugin.

That’s it!

Method 2: Install TestNG as a Software via Repository

Step 1: Launch Eclipse IDE > Navigate to “Help” menu > Click on “Install New Software” sub-menu item.

Step 2: In “Install” dialog, tap on the drop-down menu corresponding to “Work with” field and select URL: TestNG - http://beust.com/eclipse.

If you’re not able to see the URL in drop-down menu, just add the software site manually. To do that, click on “Add” button seen next to “Work with” field:

Enter “TestNG” for the “Name” field and type in http://beust.com/eclipse/ for the “Location” field. Click “OK.” After this, you should be able to see TestNG listed below.

Step 3: Select checkbox corresponding to “TestNG” and click on “Next” button.

Step 4: Eclipse will then show you the selections made for installation and calculate the software requirements to download the selected TestNG plugin. Click on “Next” on the “Install Details” screen.

Step 5: Read and accept the license agreement by clicking on “I accept the terms” radio button and hit Finish. Eclipse will now start downloading the necessary files and install the TestNG plugin.

If you encounter a security warning dialog, simply click on “Install anyway” button to proceed with the installation.

Step 6: Once the software update completes successfully, Eclipse will prompt you for a restart. Click on “Restart Now.”

Step 7: After the restart, verify the TestNG plugin installation by going to Window > Preferences. You should be able to see a TestNG section.

That’s it. We have successfully installed TestNG plugin in Eclipse.

Method 3: Install TestNG via JAR files

This method requires you to download the zipped version of TestNG from GitHub and extract the files inside Eclipse directory. You can install both release and beta version of TestNG following the below steps:

Step 1: Open https://github.com/cbeust/testng-eclipse and download the desired version of TestNG zipped file.
Step 2: Navigate to Eclipse installation folder > dropins. Inside “dropins” create a new folder named: testng-eclipse-6.14. The folder should be named based on the version you’ve downloaded. As of writing of this post, the latest release version was “6.14.0.201802161500.”
Step 3: Now open the downloaded ZIP file and you should be able to see two folders: “features” and “plugins”. Extract those folders to “testng-eclipse-6.14”

Step 4: Finally, launch Eclipse IDE and you will be able to start using TestNG in your project.