Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
20.3k views
by The go-to Tester (222 points)
retagged by
I trying to run testng with eclipse and I am getting this error

Exception in thread "main" java.lang.NoClassDefFoundError: org/testng/TestNGException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.testng.TestNGException
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)

Is there any solution for this?

3 Answers

1 like 0 dislike
by

Check Below:

1. annotations in Class 

2. TestNG Reference

1 like 0 dislike
by

Please follow following steps:

1. Add the TestNG library from in java build path for the project.

2. Right click on the project then -> Build path -> Configure build path -> Libraries tab -> Add library -> Choose TestNG and apply.

3. Create a testNG class and run the testng.xml file, it will work.

4. Right click on project -> testNG-> create testNG class -> give the details and create one method in that class then run the file.

0 like 0 dislike
by The go-to Tester (181 points)

It looks like TestNG libraries are not properly added to your build path:

If you are using Eclipse,

In Eclipse> Project > Clean

In case of IntelliJ

Go to configuration tab in TestNG "Run/Debug Configurations and select "In the whole project".

Also, if you are using maven, download all dependencies again and update your dependency tree.


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...