2

I am using following command on command line:

C:\Users\MyScriptDirectory>java -classpath ".;Lib\selenium-2.45.0\libs\testng-6.8.5.jar" org.testng.TestNG testng.xml

Getting error message:

[TestNG] [Error]

Cannot find class in classpath: com.companyname.SSProject.LaunchSSProject

I have made following entry in testng.xml:

<class name="com.companyname.SSProject.LaunchSSProject" />

"com.companyname.SSProject" is my package having LaunchSSProject.java file inside it

When I am running the same testng.xml from eclipse, it's working fine.

Does anyone know how to fix this problem? Thanks in advance

Shruti Singh
  • 180
  • 2
  • 11

3 Answers3

6

Try the following command: C:\SSProject> java -cp "path/to/your/jar/testng.jar:path/to/your/test_classes" org.testng.TestNG testng.xml

If your testng.xml is not in C:\SSProject than give the full path to the testng.xml.

SO user Patton has explained this very nicely here - How to run TestNG from command line

Updated:

For windows user, following command worked - C:\Project\Path> java -cp "path/to/your/jar/testng.jar;path/to/your/test_classes" org.testng.TestNG testng.xml

Community
  • 1
  • 1
Shubham Arora
  • 167
  • 13
0

I use testNg on windows, in the windows command prompt the execution, I use the command: java -cp bin;libs/* org.testng.TestNG testng.xml

Result: test run successfully

always on windows: I use git bash command, the command does not execute successfully

Image

Thomas Smyth - Treliant
  • 4,993
  • 6
  • 25
  • 36
Lazhar
  • 1
  • 2
0

This worked for me -- go to the project folder in command prompt and type:

java --class-path "/lib/*;/bin" org.testng.TestNG testng.xml

OR

java -cp "lib/*;bin" org.testng.TestNG testng.xml
rkta
  • 3,959
  • 7
  • 25
  • 37