Vishal Chepuri
Vishal Chepuri

Reputation: 320

How to run maven project using batch file?

This is what i have done till now:

  1. I have API automation Script in maven using testng, Following is the structure of project
    enter image description here

2.Now i first tried to run testng.xml using command-line with following command.

java -cp ".;C:\Users\A622965\.m2\repository\org\testng\testng\6.8\testng-6.8.jar" org.testng.TestNG testng.xml  

3.But throws following error:

Error: Could not find or load main class org.testng.TestNG 

Not able to figure out the issue after watching lot of tutorials.
I am looking to batch process the script using Task Schedular in Windows

Upvotes: 1

Views: 6908

Answers (2)

Little Santi
Little Santi

Reputation: 8793

Remember that Maven is a build tool, so every single operation which requires the classpath must be done through Maven, wether if you want to execute it from the command line or from some GUI.

So, in your case you will find useful the Maven command line tool:

mvn <phases>

In your case:

mvn test

But remember to include first in the pom.xml the testng library dependency, and also to properly configure the surefire plugin.

Upvotes: 1

You need to build path for testng

Right click-->Build -->Libraries Tab-->Add External jar-->Then restart--it will work...

Upvotes: 0

Related Questions