How to create a executable jar file for Testng and the runnnig point should be the Xml file

Here is the better way to do it. But thanks anyways sanbhat.

You can just create a main method which will have list of all test classes to be executed as follows:

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();
}

Here is the reference URL from the official testng website.

http://testng.org/doc/documentation-main.html#running-testng-programmatically

Cheers!


Use Eclipse Export Wizard. While exporting, select "Create Runnable Jar" and select the class which is entry point (which contains main method) of your project.

This class will have main method which will read XML and execute the testcases


You can create a main method like below and can execute it

public static void main(String[] args) {
    TestListenerAdapter tla = new TestListenerAdapter();
    TestNG testng = new TestNG();
    List<String> suites = Lists.newArrayList();
    suites.add("c:/tests/testng1.xml");//path to xml..
    suites.add("c:/tests/testng2.xml");
    testng.setTestSuites(suites);
    testng.run();
}