0

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?

Adriaan
  • 17,741
  • 7
  • 42
  • 75
Akshay
  • 135
  • 1
  • 2
  • 10
  • What IDE do you use? – Grzegorz Górkiewicz Feb 11 '17 at 16:29
  • 2
    Possible 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 Answers1

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