Please follow the below steps, these worked well for me in Eclipse.
### To Resolve "TestNG Class Not Found" Issue in Eclipse:
1. Right-click on your project in the Project Explorer.
2. Select Build Path → Configure Build Path.
3. In the Libraries tab:
- Ensure the TestNG library is listed and checked.
- If it’s missing, click Add Library → TestNG → Next → Finish.
4. Switch to the Order and Export tab:
- Check the box next to the TestNG library.
- Move TestNG to the top of the list.
5. Also ensure the JRE System Library is added and points to a valid JDK (Java Development Kit), not just the JRE.
- You don't need to move the JDK to the top, just make sure it’s checked.
6. Click Apply, then OK to save the changes.
7. Right-click the project again and select Maven → Update Project.
8. Run a Maven install to ensure dependencies are resolved:
`Run As → Maven install`
9. Finally, run your class as a TestNG Test:
`Right-click → Run As → TestNG Test`
Happy Coding!!
Cheers!
Please follow the below steps, these worked well for me in Eclipse.
### To Resolve "TestNG Class Not Found" Issue in Eclipse:
1. Right-click on your project in the Project Explorer.
2. Select Build Path → Configure Build Path.
3. In the Libraries tab:
- Ensure the TestNG library is listed and checked.
- If it’s missing, click Add Library → TestNG → Next → Finish.
4. Switch to the Order and Export tab:
- Check the box next to the TestNG library.
- Move TestNG to the top of the list.
5. Also ensure the JRE System Library is added and points to a valid JDK (Java Development Kit), not just the JRE.
- You don't need to move the JDK to the top, just make sure it’s checked.
6. Click Apply, then OK to save the changes.
7. Right-click the project again and select Maven → Update Project.
8. Run a Maven install to ensure dependencies are resolved:
`Run As → Maven install`
9. Finally, run your class as a TestNG Test:
`Right-click → Run As → TestNG Test`
Happy Coding!!
Cheers!