Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Could not find or load main class org.testng.remote.RemoteTestNG

I have written a test suite using TestNG. I have included only one test.java file for my service. I have created the testng.xml file as well. When I run the testng.xml file, I'm getting below error:

 Error: Could not find or load main class org.testng.remote.RemoteTestNG

Please let me know how to fix this. Created the test suite using this link. I ran the suite using this link.

Edits: My testng.xml looks like:

<suite name="TestAll">
  <test name="testService">
    <classes>
       <class name="com.ui.business.service.impl.myservice.test.MyServiceTest"/>
   </classes>
 </test>
 </suite>

I have kept the testng.xml in the root folder. The project compiles with Maven. My service class is in com.ui.business.service.impl.myservice package. When I run the testng.xml with "TestNG Suite", I get this error. Please suggest what to do for resolving this classpath issue.

like image 783
cleo Avatar asked Oct 05 '15 07:10

cleo


3 Answers

This worked for me:

  • Right click on your project
  • Click on Properties
  • Click on TestNG
  • Uncheck Use Project TestNG jar box
  • Click on Apply and Close
like image 75
John Alexander Betts Avatar answered Oct 16 '22 23:10

John Alexander Betts


I saw this problem when I run testNG in eclipse. I found that it's because the testng jar I included in my build was upgraded from 6.9.9 to 6.9.11. In testng 6.9.11 the class RemoteTestNG is gone. I upgraded by eclipse testng plugin from 6.9.9 to 6.9.11 and the problem is gone.

like image 34
Glenn Mi Avatar answered Oct 17 '22 01:10

Glenn Mi


Please follow the below steps, these worked well for me in Eclipse.

  1. Right click on project
  2. Go to Build path
  3. Go to Configure build path
  4. Go to Library
  5. Ticked TestNG library and if library not added then add TestNG library by click on Add Library button
  6. Go to next tab Order and Export
  7. Move TestNG to top
  8. Add JRE library as well whcih points to JDK no need to move that up just ticked.
  9. Click on Apply.
  10. Click on OK.
  11. Update project
  12. Maven install.
  13. Run class as TestNg

Happy Coding!! Cheers!

like image 42
Ashish Gupta Avatar answered Oct 17 '22 00:10

Ashish Gupta