Cannot find class in classpath issue with TESTNG

2019-07-20 14:01发布

问题:

WE are integrating testng with our application, I created testng.xml and testngbuild.xml for ant build . While running ant build it is throwing Cannot find class in classpath:. Actually I tried many ways. But I am still hopeless. Even I tried copying manually .class file to my testng directory of the application. If you can do like this, It is throwing another exception as could not load .class file

回答1:

Even I faced the same problem many a times. You can try below solutions which worked for me.

  1. Click on specific project ->Project->Clean-> refresh

  2. Because of other open projects in IDE. Keep only the project you are working on open and close other non related projects. Right click-> Close Project.

  3. And you won't believe sometimes the culprit is Excel sheet(Don't know how it is related) when you have it open and sepearate instance might have created with that etc. Close it and kll any process running with excel sheet will resolve.