I find the need to maintain and edit testng.xml despite the availability of annotations as a limitation of TestNG. Is it possible to either automate the generation of testng.xml, or completely eliminate the need for it while running unit tests?
Asked
Active
Viewed 83 times
1 Answers
2
From testng.org documentation: "You can invoke 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 it Here: http://testng.org/
Here is one Stack Discussion on the simillar topic
A working example class on Github

Community
- 1
- 1

Chandan Nayak
- 10,117
- 5
- 26
- 36
-
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – beresfordt Jun 28 '15 at 15:59