Error: org.testng.TestNGException: Cannot find class in classpath: EmpClass
I also got the same exception:
I tried the following steps:
In Eclipse> Project > Clean. (The Exception remained)
I ran another project(The testng.xml ran successfully)
After running another project, I ran the project in which I was getting the Exception, and fortunately it worked for me, with no errors.
You have to edit your tests Runner xml file.See this example:
<test name="Employees Test"> <classes> <class name="packagename.classname"> </class> </classes> </test>
In <class name="packagename.classname">
row you must enter your tests package name then name of class that you want to run.
Thanks and wish you all the best.
I faced the similar issue on importing maven with testng project. This was solved by converting again into TestNg project by
right click on eclipse project > TestNG > Convert to TestNG
and replacing the existing testng.xml
file with the newly created. Clean and update the maven project with mvn install
Note: take backup of your testng.xml