How To Run TestNG Using Command Prompt | Software Testing Material
Goal: To Run TestNG using Command Prompt:
Steps to achieve our goal – Executing TestNG using Command Prompt:
- Open Eclipse and create a Java class
- Write a Java program
- Convert the Java Program into TestNG
- Open command prompt
- Run the TestNG using command prompt
Here is a video tutorial to learn “How To Run TestNG Using Command Prompt”:
Please be patient. The video will load in some time.
Step i: Open Eclipse and create a Java class
Step ii. Keep all the library files in a folder (here I create a folder name “lib”)
Step iii: Write a Java program
Step iv: Convert the Java Program into TestNG
Step v: Open command prompt
Step vi: Run the TestNG using command prompt
C:\Users\Admin\Desktop\STMSeleniumTutorial\workspace\SoftwareTestingMaterial
set classpath=C:\Users\Admin\Desktop\STMSeleniumTutorial\workspace\SoftwareTestingMaterial\bin;C:\Users\Admin\Desktop\STMSeleniumTutorial\workspace\SoftwareTestingMaterial\lib\*
java org.testng.TestNG C:\Users\Admin\Desktop\STMSeleniumTutorial\workspace\SoftwareTestingMaterial\testng.xml
Also you could run TestNG using Batch file (.bat file)
Copy the below code and place it in a notepad and save the file using .bat extension
set projectLocation=C:\Users\Admin\Desktop\STMSeleniumTutorial\workspace\SoftwareTestingMaterial cd %projectLocation% set classpath=%projectLocation%\bin;%projectLocation%\lib\* java org.testng.TestNG %projectLocation%\testng.xml pause
You could find the complete TestNG tutorial here.
If you are not a regular reader of my blog then I highly recommend you to signup for the free email newsletter using the below link.
i tried to add the all jar files in lib folder but i am getting Webdriver Exception cannot be resolved and also it’s not importing the pre-definied class
Share your code here vishnu
Hello,
Thank you so much ..
Its working for me.
But I am not able call back to back two classes from tesNG.xml throgh cmd
Follow my TestNG Tutorial. You have to place two classes in testng.xml file and call that testng.xml using command prompt.