Welcome QA Warriors and Automation Heroes! 💻🔥
Today, we’re unlocking the power of TestNG – the core of Java-based test automation – and setting it up inside Eclipse. This is your end-to-end TestNG setup journey, packed with tips, walkthroughs, and real test examples!
Let’s go from zero to TestNG pro – step by step! 🚀
🔥 What is TestNG?
TestNG stands for Test Next Generation.
It’s an open-source testing framework inspired by JUnit but with supercharged features!
TestNG gives you:
Advanced annotations
Parallel execution
Dependency-based testing
Data-driven testing
Built-in HTML reports
It’s a favorite in the Selenium world for automation testing with power and structure.
⚙️ Prerequisites
Before we dive in, make sure you’ve got:
Eclipse IDE (latest recommended)
Java JDK installed (version 8 or above)
A basic understanding of Java and how to create projects in Eclipse
All set? Let’s go! 💨
🚀 Step 1: Install TestNG Plugin in Eclipse
Open Eclipse
Go to Help → Eclipse Marketplace
In the search bar, type TestNG
Click Go, find TestNG for Eclipse
Click Install → Next → Accept License → Finish
Restart Eclipse if prompted
💡 Boom! Eclipse is now TestNG-ready!
🛠️ Step 2: Create a Java Project
Go to File → New → Java Project
Name it TestNGDemo
Click Finish
🎉 Your project foundation is ready!
📁 Step 3: Create Packages and Classes
Right-click on src → New → Package → name it testcases
Right-click on testcases → New → Class → name it LoginTest
(Optional) Check the box for main method, but you don’t need it for TestNG
You’ve now created the test structure for your scripts.
📚 Step 4: Add TestNG to Your Project
Option 1: Maven (Recommended for larger projects)
Right-click project → Configure → Convert to Maven Project
In the pom.xml, add the following dependency:
groupId is org.testng, artifactId is testng, version is 7.9.0, scope is test
Save the file and let Maven auto-download the dependencies
Option 2: Manual JAR (For smaller projects)
Go to testng.org and download the latest jar file
Right-click project → Build Path → Configure Build Path → Libraries → Add External JARs
Select your downloaded TestNG jar
📌 TestNG is now plugged into your project!
🧪 Step 5: Create Your First TestNG Test
Let’s write our first test class inside the testcases package. Here's how it looks (spoken, not coded):
The class name is LoginTest
It contains two methods: one for logging in with valid credentials and one for invalid credentials
Each method is annotated with atTest, marking them as TestNG test cases
The methods print messages like "Login with valid credentials test passed" and "Login with invalid credentials test failed"
That’s it! Your test file is ready to run.
🚦 Step 6: Run Your Test
Right-click the class file
Choose Run As → TestNG Test
You’ll see something like:
PASSED: loginWithValidCredentials
FAILED: loginWithInvalidCredentials
(Note: These are just print statements, not real assertions yet!)
💡 Quick Recap:
Installed TestNG in Eclipse ✅
Created Java Project and Test Class ✅
Integrated TestNG via Maven or Manual JAR ✅
Wrote and ran your first TestNG test ✅
You’re officially on your way to becoming a TestNG Ninja! 🥷
Hit like, subscribe, and stay tuned for the next video where we dive into assertions, reports, and test suites.
🏷️ Hashtags
#TestNG, #JavaAutomation, #EclipseIDE, #AutomationTesting, #SeleniumJava, #TestNGSetup, #QAEngineering, #TestAutomation, #MavenTestNG, #JavaTesting, #EclipseTestNG, #EndToEndTesting, #AutomationFramework, #JavaQA, #SoftwareTesting, #JUnitVsTestNG, #TestNGTutorial, #QualityAssurance, #SDET, #TestDrivenDevelopment