How to run Selenium Tests from command line usingTestNG - Bug Reaper

                  Bug Reaper

Lean about Automation Testing,Selenium WebDriver,RestAssured,Appium,Jenkins,JAVA,API Automation,TestNG,Maven, Rest API, SOAP API,Linux,Maven,Security Testing,Interview Questions

Sunday 30 November 2014

How to run Selenium Tests from command line usingTestNG

We can run Selenium TestNG Tests from command line directly without eclipse.


For this you will need to create testng.xml file mentioning all the cases.


Steps:
1.)Open cmd---> Win+R type cmd.
2.) In Command prompt browse to project location
i.e. cd C:\Workspace\projectname
3.)Type java -cp C:\Workspace\projectname\lib\*;C:\Workspace\projectname\bin org.testng.TestNG testng.xml


OR
 java -cp C:\Workspace\projectname\bin; C:\Workspace\projectname\lib\* org.testng.TestNG testng.xml


Note: Here 'cp' stands for compile and will pick the class file of the project present in bin folder


Similarly the TestNg Jar will be taken fro lib folder of the project.


For a better practice we can set the Project path and Class path
1.)Go To cmd.

2.) Type set ProjectPath=C:\Workspace\projectname

echo %ProjectPath%

3.)set classpath=%ProjectPath%\bin;%ProjectPath%\lib\*
echo %classpath%

4.)java org.testng.TestNG %ProjectPath%\testng.xml


No comments:

Post a Comment