Reputation: 109
I'm trying to run TestNG
from command line, but it's giving me error.
Can someone tell me where am I going wrong?
java -cp C:/TestNG directory/testng-6.2.jar;C:\project directory\src\com\suites\suite\shop org.testng.TestNG testng.xml
Error: Could not find or load main class org.testng.TestNG
My scripts runs fine when I ran them from eclipse testng plugin
.
Upvotes: 8
Views: 87979
Reputation: 2407
My Assumptions:
You are trying to run test file from command prompt
libs folder generated under Project/tagret upon using "mvn clean package -DskipTests"
class file generated under Project/target/test-classes/package-name
With above assumptions in mind, you can follow below process.
Setting class path in command prompt:
1. Open project location in command prompt
2. set classpath=C:\User\SeleniumTestProject\target\test-classes;C:\User\SeleniumTestProject\target\libs\*
3. java org.testng.TestNG C:\User\SeleniumTestProject\testng.xml
Upvotes: 1
Reputation: 21
Check that the lib folder contains testng-6.8.jar(or any other version) file because testng.xml even executes successfully without testng-6.8.jar (or any other version) with the jars that gets added when we add TestNG library.
Upvotes: 0
Reputation: 21
Possibly your testng.jar file is not in the lib folder that C:\Workspace\projectname\lib
.
You should find testng.jar first in your computer and move it manually to C:\Workspace\projectname\lib
. Then it will work
Upvotes: 2
Reputation: 21169
Copy the below commands in a text file.
Edit the location.
Save it as yourtext.bat
Now, double click on the batch file created.
cd C:\Workspace\projectname
java -cp C:\Workspace\projectname\lib*;C:\Workspace\projectname\bin org.testng.TestNG testng.xml
Upvotes: 10
Reputation: 361
testng.jar
. From link testng.org, please click "here for ant users" to download a full testng.jar(11 mega bytes), not a "Maven Central" version(no more than 100k).I have tested those two versions on centos following testng tutorial point
Upvotes: 2
Reputation: 69
Path of TestNG.jar file was not set up. Follow instructions of following site to set up. It worked for me: http://qtp-automate.blogspot.com/2011/10/running-selenium-testng-test-from.html
Upvotes: 4