I'm trying to run testng via command line and I have following things in classpath:
testng
jar, jar of compiled test case file, and other required jars.testng.xml
points to appropriate class in the hierarchy.
Testng doesn't run instead it throws:
[TestNG] [ERROR] Cannot find class in classpath: (name of testcase file)
I encountered the same issue before and I just added.
In classpath
and it solved the problem. But this time it did not seem to solve it. Any workarounds? Thanks in advance.
add to pom:
I was getting the same error - Cannot find class in classpath:
Solution: I had committed following mistakes:
i was facing same issue solution is , you need to check testng file,your class created under package in this case class is not found through Test NG. perform below steps just convert your project in to Test NG and over write/rplace with new testNG file.
Again run this TestNG in this case it is working my case,
I have faced the similar issue when I tried to execute my Testng.xml file.
To fix you should move your class file from default pkg to some other pkg; ie create a new pkg and place your class file there
Clean your project (Project → Clean) even if this didn't work just delete the target directory for that module as well as of other module on which your project is dependent.
Check the class hierarchy. If the package is missing in your class you'll get this error. So, try to create a new testing class by selecting the package.