How to Install and Add TestNG in Eclipse

On This Page What is TestNG Framework?Features of TestNG

May 23, 2026 · 7 min read · Testing Guide

How to Install and Add TestNG in Eclipse

Integrating TestNG with Eclipse, which is one of the most normally use IDEs among developers and testers, helps streamline the examination workflow. This guide walks you through the various shipway of installing in Eclipse, assist you set up your examination mechanisation environment quickly and efficiently.

What is TestNG Framework?

is a Unit testing fabric for Java inspired by and, which allows you to run your exam apply. It is popular because of the Annotations compass it supports as compared to JUnit.

Features that make TestNG Framework so popular are:

  • Wide ambit of Annotations Support.
  • Support
  • Pliant execution model viaTestng.xmlconfiguration
  • Concurrent examination: TestNG runs tests in arbitrarily big thread pools with various policies uncommitted (all methods in their own thread, one thread per test class, etc.) and tests whether the code is multithread safe.
  • Parallel Run support: With, multiple tests can be run simultaneously, supporting prove at scale in lesser time.

Read More:

Features of TestNG

Here are the main features of TestNG:

1. Test Configuration:TestNG offers a set of annotations to configure pre-test and post-test conditions expeditiously. Annotations like @ BeforeSuite, @ BeforeTest, and @ BeforeMethod assistance set up the surroundings or initialize resources before trial run. Similarly, @ AfterSuite, @ AfterTest, and @ AfterMethod are used for clean-up activity after the test performance. This structured setup create trial shape simpleton and organized.

2. : TestNG supports data-driven testing through the @ DataProvider annotating, permit you run the same test method with multiple remark data set. This is utilitarian for testing input combination like positive, negative, and random values, making your tryout scenarios more robust and comprehensive.

3. Execution: TestNG enables parallel test execution, importantly reducing total performance time. This feature is handy when executing large test entourage, as it meliorate efficiency by executing tests concurrently across ribbon or machines.

4. Managing Test Dependencies and Groups: TestNG helps define dependencies between test methods. For instance, if a login test depends on successful user registration, and the enrolment test fails, the login test will be hop.

Additionally, TestNG support grouping of test based on features or modules, enabling easygoing arrangement and direction of complex test instance.

5. Test Assertions: In TestNG, affirmation validate expected outcomes against existent results. With built-in assertion method like assertEquals (), assertTrue (), and assertFalse (), testers can verify application behavior efficiently and ascertain that the system under test performs as expected.

Read More:

What is Eclipse

Eclipse is a democratic open-source Integrated Development Environment (IDE), essentially used for Java development. However, it supports many other scheduling languages through plugins.

Read More:

Different mode to run TestNG Test

TestNG tests can be run using two different methods as follows:

  • Inside IDE (LikeEclipse)
  • Via Maven Profile through Command Line

Running tests within IDE is needed during the evolution and debugging of the TestNG exam. While, Maven Profile is used when you need to execute all the exam outside the IDE, like executing the TestNG tests from Jenkins.

How to install TestNG in Eclipse

To configure Eclipse you need to perform the following:

  1. Add TestNG to Eclipse using TestNG Plugin configuration and Run
  2. Creating Sample Maven Project by impart TestNG dependency

How to Install and Add TestNG in Eclipse

Step 1:Navigate to Eclipse Marketplace

Step 2:Search for TestNG and pawl on install.

Note:After the plugin is installed, re-start the Eclipse IDE

As the plugin is installed, you can see Options like Run All, Run | Debug in the editor itself, and clicking on Run above the TestNG Test will action the examination likewise Debug will grant debugging the test.

Adding a TestNG plugin within the Eclipse IDE helps in making the test execution easier by directly running the tests inside the Text Editor itself. Hence, it is advocate to configure the TestNG Plugin in Eclipse to run Unit Tests.

Creating Sample Maven Project by add TestNG dependency

Here are the steps to create Sample Maven Project and how to add TestNG Dependencies:

Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script.

Step 1:Create a new Maven Project by opening eclipse. Click onNew & gt; Select Maven Project

Step 2:Select the quickstart Archetype

Step 3:Enter Group ID, Artifact ID, and Finish the setup process

Step 4:New Maven labor is created and all our tests will be indite inside leafletsrc/test/javaand boxcom.test.selenium.v1

Step 5:Add dependencies to thePOM.xml file

Add the below dependencies to thePOM.xml file

& lt; project xmlns= '' http: //maven.apache.org/POM/4.0.0 '' xmlns: xsi= '' http: //www.w3.org/2001/XMLSchema-instance '' xsi: schemaLocation= '' http: //maven.apache.org/POM/4.0.0 http: //maven.apache.org/xsd/maven-4.0.0.xsd '' & gt; & lt; modelVersion & gt; 4.0.0 & lt; /modelVersion & gt; & lt; groupId & gt; com.testng.selenium & lt; /groupId & gt; & lt; artifactId & gt; Testng-selenium & lt; /artifactId & gt; & lt; edition & gt; 0.0.1-SNAPSHOT & lt; /version & gt; & lt; packaging & gt; jar & lt; /packaging & gt; & lt; name & gt; v1 & lt; /name & gt; & lt; url & gt; http: //maven.apache.org & lt; /url & gt; & lt; properties & gt; & lt; project.build.sourceEncoding & gt; UTF-8 & lt; /project.build.sourceEncoding & gt; & lt; /properties & gt; & lt; dependencies & gt; & lt;! -- https: //mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -- & gt; & lt; dependency & gt; & lt; groupId & gt; org.seleniumhq.selenium & lt; /groupId & gt; & lt; artifactId & gt; selenium-java & lt; /artifactId & gt; & lt; adaptation & gt; 4.2.1 & lt; /version & gt; & lt; /dependency & gt; & lt;! -- https: //mvnrepository.com/artifact/org.testng/testng -- & gt; & lt; dependency & gt; & lt; groupId & gt; org.testng & lt; /groupId & gt; & lt; artifactId & gt; testng & lt; /artifactId & gt; & lt; variant & gt; 7.6.0 & lt; /version & gt; & lt; range & gt; test & lt; /scope & gt; & lt; /dependency & gt; & lt; /dependencies & gt; & lt; /project & gt;

Step 6:Add a new Class to the software

Step 7:Add a TestNG test to the newly make class

import java.io.File; significance org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.AfterTest; significance org.testng.annotations.BeforeTest; import org.testng.annotations.Test; public class SeleniumTestngTest {WebDriver driver; @ BeforeTest public void initDriver () {String path = System.getProperty (`` user.dir '') + File.separator + `` driver '' + File.separator + `` chromedriver-2 ''; System.setProperty (`` webdriver.chrome.driver '', path); WebDriver driver=new ChromeDriver (); driver.manage () .window () .maximize ();} @ Test public void firstTest () {driver.get (`` https: //www.bstackdemo.com/ '');} @ AfterTest world void tearDown () {driver.close (); driver.quit ();}}

Follow Up Read:

Talk to an Expert

Install TestNG using Install New Software

The “ Install New Software ” pick in Eclipse can be opted when the Eclipse Marketplace do not offer the plugin you require or when you prefer installing directly from a plugin ’ s update situation URL.

Here ’ s a step-by-step guide to instal TestNG in Eclipse using the & # 8220; Install New Software & # 8221; option:

Step 1: Open Eclipse IDE and Navigate to:

Help & gt; Install New Software

Step 2: In the “ Work with ” field, input the official TestNG update site URL: 

https: //testng.org/testng-eclipse-update-site

Step 3: Press Enter. Eclipse will then get the available package.

Step 4: Select “ TestNG ” from the list.

Step 5:Click Next. Eclipse will figure dependencies.

Step 6: Click Next again on the reexamination blind.

Step 7: Accept the license agreement. Then, Click Finish

Step 9 : Installation will begin. You may see a warning around unsigned content. Click “ Install Anyway ”.

Step 10 : Once installation is complete, restart Eclipse when prompted.

Step 11: Verify TestNG Installation:

After restarting:

  • Go to Window & gt; Preferences
  • Look for TestNG in the left panel
  • If it appears, TestNG is successfully establish

How to Set Up TestNG Eclipse Tests From Your Existing Java Projects

Here ’ s a step-by-step to set up TestNG Eclipse Tests From Your Existing Java Projects:

Step 1: Open Your Existing Java Project

Make sure that you have TestNG involve before you start with the following:

  1. Launch Eclipse.
  2. Open your existing Java task from the Project Explorer.

Step 2: Add TestNG to the Project Build Path

  1. Right-click on your project & gt; Build Path & gt; Configure Build Path
  2. Then, navigate to the Libraries tab. Click Add Library & gt; Select TestNG & gt; Next & gt; Finish
  3. Click Apply and Close

With this, you have colligate TestNG to your project.

Step 3: Create a New TestNG Class

  • Right-click on src folder & gt; New & gt; Other
  • Search for TestNG Class, click Next
  • Name your grade (e.g., LoginTests)
  • Select desired notation like @ BeforeMethod, @ Test, etc.
  • Click Finish

This will generate a skeleton examination class with TestNG annotations.

Step 4: Run the Test

  • Right-click the TestNG class & gt; Run As & gt; TestNG Test
  • Get results in the TestNG Results tab

Optional: Convert Existing Java Class to TestNG

If you already have a test class written in plain Java:

  • Right-click the class file & gt; Convert to TestNG

Conclusion

By installing TestNG in Eclipse, testers can streamline their automation workflow and fully utilize the framework ’ s robust capacity.

When use along with tools like BrowserStack, you can run your TestNG test suites on a wide range of real devices and browsers (3500+) in the cloud. This see broader test reporting and speeds up the testing rhythm, enabling faster and dependable releases.

Useful Resources for TestNG

Tags
85,000+ Views

# Ask-and-Contributeabout this theme with our Discord community.

Related Guides

Automate This With SUSA

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.

Try SUSA Free

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free