How to run TestNG from command line
You need to have the testng.jar
under classpath.
try C:\projectfred> java -cp "path-tojar/testng.jar:path_to_yourtest_classes" org.testng.TestNG testng.xml
Update:
Under linux I ran this command and it would be some thing similar on Windows either
test/bin# java -cp ".:../lib/*" org.testng.TestNG testng.xml
Directory structure:
/bin - All my test packages are under bin including testng.xml
/src - All source files are under src
/lib - All libraries required for the execution of tests are under this.
Once I compile all sources they go under bin directory. So, in the classpath I need to specify contents of bin directory and all the libraries like testng.xml, loggers etc over here. Also copy testng.xml to bin folder if you dont want to specify the full path where the testng.xml is available.
/bin
-- testng.xml
-- testclasses
-- Properties files if any.
/lib
-- testng.jar
-- log4j.jar
Update
:
Go to the folder MyProject
and type run the java command like the way shown below:-
java -cp ".: C:\Program Files\jbdevstudio4\studio\plugins\*" org.testng.TestNG testng.xml
I believe the testng.xml file is under C:\Users\me\workspace\MyProject
if not please give the full path for testng.xml
file
Running TestNG via Command Line
Try:
java -cp ".;C:\Users\johndoe\Documents\My Docs\03_OE\Java\workspace\Maven\m2\repository\org\testng\testng\6.9.10\testng-6.9.10.jar;C:\Users\johndoe\Documents\My Docs\03_OE\Java\workspace\Maven\m2\repository\com\beust\jcommander\1.48\jcommander-1.48.jar;C:\Users\johndoe\Documents\My Docs\03_OE\Java\workspace\KeywordDrivenTool\JavaTestNBS\target\test-classes" org.testng.TestNG test.xml
Related Topics
Lambda Expression and Generic Defined Only in Method
How to Replace the Awt Eventqueue with Own Implementation
Lombok Annotations Do Not Compile Under Intellij Idea
How to Format Decimals in a Currency Format
Program Freezes During Thread.Sleep() and with Timer
Use Cases and Examples of Gof Decorator Pattern for Io
Java Lambdas 20 Times Slower Than Anonymous Classes
How to Match String Within Parentheses (Nested) in Java
Differencebetween a Javabean and a Pojo
Solve Hibernate Lazy-Init Issue with Hibernate.Enable_Lazy_Load_No_Trans
How to Find Nth Occurrence of Character in a String
Java Error: Only a Type Can Be Imported. Xyz Resolves to a Package
How to Create Custom Methods for Use in Spring Security Expression Language Annotations
How Can Non-Ascii Characters Be Removed from a String
Java Gui Frameworks. What to Choose? Swing, Swt, Awt, Swingx, Jgoodies, Javafx, Apache Pivot
How to Change the Intellij Idea Default Jdk
Maven Error: Could Not Find or Load Main Class Org.Codehaus.Plexus.Classworlds.Launcher.Launcher