Install TestNG In Eclipse & IntelliJ?
1. Installing TestNG in Eclipse
A. Via Eclipse Marketplace (recommended)
- Help → Eclipse Marketplace…
- Search for “TestNG”
- Click Install on the “TestNG for Eclipse” entry
- Follow the prompts and restart Eclipse when prompted
B. Via Update Site
- Help → Install New Software…
- Work with: https://testng.org/testng-eclipse-update-site
- Check TestNG in the list, click Next, accept licenses, and finish
- Restart Eclipse
C. Add TestNG to Your Project
- Plain Java (no build tool):
- Right-click your project → Build Path → Add Libraries… → choose TestNG
- Maven: add to your pom.xml:
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.7.0</version> <!-- or latest -->
<scope>test</scope>
</dependency>
then Project → Maven → Update Project
- Gradle: add to build.gradle:
dependencies {
testImplementation 'org.testng:testng:7.7.0'
}
test {
useTestNG()
}
2. Installing TestNG in IntelliJ IDEA
A. Enable/Install the TestNG Plugin
- File → Settings (⌘, on macOS) → Plugins
- Search for “TestNG”
- If not installed, click Install; otherwise ensure it’s Enabled
- Restart IDEA if prompted
Note: IntelliJ Ultimate bundles TestNG support by default. In Community Edition you may need the plugin.
B. Add TestNG to Your Project
- Maven: same pom.xml snippet as above; then Maven → Reimport
- Gradle: same build.gradle snippet; then Reload Gradle Project
- Plain Java:
- File → Project Structure → Libraries
- Click + → From Maven…, search org.testng:testng:7.7.0, add it
- Apply and close
C. Creating a TestNG Run Configuration
- Run → Edit Configurations…
- Click + → TestNG
- Give it a name (e.g. “All Tests”); choose Suite, Package, Class, or Method
- If using an XML suite, point Suite to your testng.xml
- Apply and Run
3. Verify Your Setup
1. Create a simple TestNG class:
import org.testng.annotations.Test;
public class HelloTest {
@Test
public void hello() {
System.out.println("TestNG is working!");
}
}
2. Right-click the class → Run ‘HelloTest’ (Eclipse) or click the green ▶ (IntelliJ).
3. You should see TestNG results in the console / TestNG Results view.
With those steps you’ll have TestNG installed, added to your project’s classpath, and ready to write & run your Selenium (or any) tests!