Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am currently working on the selenium web driver and testng on Eclipse IDE. I usually run the test from the XML file that i have created which runs all the methods in the eclipse.

Now i want to create a simple executable jar which should do the same i.e its running point should be the XML file so that each test is executed .

I am trying hard on this. Please give me some advice on how to go further with it

like image 402
mannu singh Avatar asked May 06 '13 06:05

mannu singh


People also ask

How do I create a TestNG XML jar?

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.


1 Answers

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!

like image 154
mannu singh Avatar answered Sep 20 '22 00:09

mannu singh