Create test reports programmatically (not using AN

2019-07-15 14:09发布

问题:

I want to create test reports (reports generated after the execution of each test case). I can generate JUnit test reports using ANT. But, my requirement is such that I would have to generate these reports through Java.

Which is the best way to create test reports using Java ?

The test reports need not only be created in JUnit. It can be created in any test framework. Any suggestions / advice related to it might prove helpful. So, request you to share you experience in generating test reports using Java.

回答1:

TestNG reports get generate automaticlly if you run a suite(xml). Standard folder is test-output in your project. Have a look at the testNG doc at chapter 6.2.2 and following http://testng.org/doc/documentation-main.html how to customize those.



回答2:

TestNG provides a programmatic way to run the tests without using any build file. TestNG suite and other parameters that are being used in build XML have corresponding JAVA classes. Check this link. http://testng.org/doc/documentation-main.html#running-testng-programmatically

You can get the report as mentioned by Tarken.