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.
simple solution was to remove .java extension from class path name. and it worked for me
Update TestNG plugin and It will work.
Please make sure that you have specified your class/package in TestNG.xml file.
Before running the command for testng.xml file from command prompt, please check the following if you are missing them
set CLASSPATH
and include the testng jar file location, selenium-server jar file location(if you are working with selenium webdriver), bin folder location of your project which contains all the .class files of your project.e.g.,
set CLASSPATH=C:\Selenium\testng-5.8-jdk15.jar;C:\Selenium\selenium-server-standalone-2.31.0.jar;C:\SeleniumTests\YourProject\bin
java org.testng.TestNG testng.xml.
I was into the same situation but the above things worked for me.
I had to make a jar file from my test classes and add it to my class path. Previously I added my test class file to class path and then I got above error. So I created a jar and added to classpath.
e.g
This issue is coming due to some build error. 1. Clean Project - if issue not resolve 2. update maven project - If still not resolved 3. Go to build path from (right click on project- > properties -> java build path) now check library files. if you see an error then resolve it by adding missing file at given location.
I face the same issue, after lots of approaches I found 3rd solution to get that issue fixed