Below are the steps showing how you can install Testng on different popular IDEs that is Eclipse, IntelliJ IDEA, and for use with Maven/Gradle projects.
1. Installing TestNG in Eclipse
Method 1: Using Eclipse Marketplace
- Open Eclipse.
- Go to
Help
→Eclipse Marketplace
. - In the Find box, type
TestNG
. - Click Go and find TestNG for Eclipse.
- Click Install, accept the license, and finish.
- Restart Eclipse.
Verify Installation:
Right-click on your project →
New
→Other
→ Search for TestNG Class.You should also see a TestNG tab in the menu bar.
2. Installing TestNG in IntelliJ IDEA
Method 1: Enable Built-in Support
- Open IntelliJ IDEA.
- Go to
File
→Project Structure
. - Select
Modules
→Dependencies
. - Click + → Select Library → Choose From Maven.
- Type: org.testng:testng:7.9.0
- Click OK to download and add to your project.
Method 2: Add to Maven
pom.xml
<dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>7.9.0</version> <scope>test</scope> </dependency>
IntelliJ will auto-download the dependency.
Verify Installation:
Right-click a class →
Run as TestNG Test
.Check
Run Configurations
→ You should seeTestNG
.
3. Using TestNG with Gradle Projects
Add to build.gradle
:
dependencies { testImplementation 'org.testng:testng:7.9.0' } test { useTestNG() }
Run:
gradle test