Hi Bharath,
To execute jar, it need to specify some entry point .i.e., mainfest class.
You need to create new java class which has main method calling testng run.
Then mention above path of java class as mainfest attribute in maven pom.xml file
Below is sample code of java class that need to be added:
import java.io.File;
import java.util.List;
import org.testng.TestListenerAdapter;
import org.testng.TestNG;
import org.testng.collections.Lists;
public class ExecuteTestSuite {
public static void main(String[] args) {
TestListenerAdapter tla = new TestListenerAdapter();
TestNG testng = new TestNG();
List<String> suites = Lists.newArrayList();
suites.add(new File("Path to testng suitefile").getAbsolutePath().toString());
testng.setTestSuites(suites);
testng.addListener(tla);
testng.run();
System.out.println("Test Completed!!");
}
}
Tip: There are lot thing that we can do with testng listeners, just google it!
Add below line in maven pom file:
<manifest>
<mainClass>package path to ExecuteTestSuite class</mainClass>
</manifest>
Hope this helps.
Thanks
Dinesh