Tuesday, 15 October 2013

Batch file[.bat] to invoke testng.xml and run tests | TestNG

Executing tests from a .bat file is familiar or useful while using GRID. There are couple of ways to execute this.

1| Copy any one of the below methods in text file
2| Edit the drive location
3| Save it as yourtext.bat
4| Now, double click on the batch file created.

Note: Its better to execute from cmd prompt before try

Method #1
cd C:\Workspace\projectname
java -cp C:\Workspace\projectname\lib\*;C:\Workspace\projectname\bin org.testng.TestNG testng.xml

Method #2
cd C:\Workspace\projectname
set ProjectPath=C:\Workspace\projectname
echo %ProjectPath%
set classpath=%ProjectPath%\bin;%ProjectPath%\lib\*
echo %classpath%
java org.testng.TestNG %ProjectPath%\testng.xml


  1. which lib folder are you referring to here?
    I am running my selenium script from eclipse and I can't find any lib folder in my workspace project folder.
    Any help would be appreciated.

  2. could not find or load main class org.testng.Testng

    whats this mean

  3. Thanks for the great information in your blog Selenium Training in Chennai

  4. My Eclipse script reads data from Excel through DataProvider. Testng.xml works fine when i run it from Eclipse>Run As>TestNG Suite. But if i try to run it from bat file it fails with no error message.

  5. to execute maven project through jenkin what to write in .bat file

  6. I prefer to study this kind of material. Nicely written information in this post, the quality of content is fine and the conclusion is lovely. Things are very open and intensely clear explanation of issues
    python Training institute in Pune
    python Training institute in Chennai
    python Training institute in Bangalore

  7. Great thoughts you got there, believe I may possibly try just some of it throughout my daily life.
    Best Devops online Training
    Online DevOps Certification Course - Gangboard