4
votes

I need to create a Executable Jar file for the Selenium Webdriver Project (TestNG) using Eclipse.

After crawling various website I understand we need to create a Main Class to execute the Test Suite.

I have created a Main Class with below code.

package com.testcases;
import java.util.ArrayList;
import java.util.List;
import org.testng.TestListenerAdapter;
import org.testng.TestNG;
import org.testng.xml.XmlClass;
import org.testng.xml.XmlSuite;
import org.testng.xml.XmlTest;

public class Main {
public static void main(String[] args) {
    // TODO Auto-generated method stub
    TestListenerAdapter tla = new TestListenerAdapter();
    TestNG testng = new TestNG();
     Class[] classes = new Class[]{
             Abc.class,
             PQR.class,
             XYZ.class
             };
     testng.setTestClasses(classes);
     testng.addListener(tla);
     testng.run();
    }
}

When, I have created a runnable Jar using Export->Java->Runnable Jar from Selenium, and after running through jar file using command prompt with below command:

java -jar AbcXyz.jar

Program Execution get into the Infinite loop

Please help for creating such Executable Jar file.

Below are some References: Testng

1
Did you create any method to stop test? I think you should. - Helping Hands
I am still in process to create such a Main class file for the Project. Kindly, help for the same.. The Classes Abc.java, pqr.java and xyz.java are purely TestNG files and does not consists Main file. - Chetan G
does testNG file runs properly? - Helping Hands
Yes - The TestNG file with Main() runs successfully. - Chetan G
cant you run the jar file as TestNG test directly ? - Sighil

1 Answers

0
votes

Did you end your tests with
driver.quit();

This could be the reason