I have a script written in Selenium using the TestNG framework. This script executes via an xml file. Since we do not have main method in this, how can I export this script to a runable JAR file?
Asked
Active
Viewed 615 times
0
-
What IDE do you use? – Grzegorz Górkiewicz Feb 11 '17 at 16:29
-
2Possible duplicate of [How to create a executable jar file for Testng and the runnnig point should be the Xml file](http://stackoverflow.com/questions/16393223/how-to-create-a-executable-jar-file-for-testng-and-the-runnnig-point-should-be-t) – djangofan Feb 11 '17 at 17:01
1 Answers
0
I marked this question as a dupe (and this code snippet comes from the dupe question), but basically you could write a public static void main method that scans for tests or loads a existing testng.xml file. Then, you just need to use something such as Maven Shade plugin to package it.
public static void main(String[] args) {
TestListenerAdapter tla = new TestListenerAdapter();
TestNG testng = new TestNG();
testng.setTestClasses(new Class[] { test_start.class });
testng.addListener(tla);
testng.run();
}
I used WebDriverManager project to manage my driver libraries. I would have the .jar load those externally.

djangofan
- 28,471
- 61
- 196
- 289
-
I tried it also but getting "Command line suite" in the console and nothing else. – Akshay Feb 11 '17 at 18:18
-
Just read the TestNG documentation. There are also other similar examples around the web. – djangofan Feb 11 '17 at 21:09
-