Site icon TestingDocs.com

How to fix the Error Unable to initialize main class RemoteTestNG

When we try to run TestNG tests, we get the following exception. Unable to initialize main class org.testng.remote.RemoteTestNG

Error Trace

Error: Unable to initialize main class 
org.testng.remote.RemoteTestNG 
        Caused by: java.lang.NoClassDefFoundError: org/testng/TestNGException


 

Root cause

TestNG library is not found in the classpath. The fix for the error depends on the environment on how the tests are run. If the error occurs while running tests in Eclipse IDE, add the TestNG library to the project build path.

Right-click on the Package explorer choose, Build Path >> Configure Build Path…

In the Java Build Path screen, Select the Libraries tab, click on the Add Library… button.

Choose TestNG and click on the Next button.

Click on the Finish button and Apply the action to save the setting.

 

 

This will add the TestNG to the project. Run the TestNG tests. This will solve the exception and tests would run successfully.

 

Exit mobile version