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.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
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.
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
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
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
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