Eliminating the need for testng.xml when running Java unit tests in TestNG
1 answer
From testng.org documentation: "You can call TestNG from your own programs very easily":
TestListenerAdapter tla = new TestListenerAdapter();
TestNG testng = new TestNG();
testng.setTestClasses(new Class[] { Run2.class });
testng.addListener(tla);
testng.run();
This example creates a TestNG object and runs the test class Run2. It also adds a TestListener.
Ref:
You can read more about this here: http://testng.org/
one Stack Discussion on simillar topic
Working example class on Github
+2
source to share