Run task after each test case

时间:2016-08-31 18:54:32

标签: java junit testng code-coverage jacoco

I am trying to develop a tool to perform some internal data mapping of test cases. To be precise, I want to map which test case hits which all classes and methods. I plan to take JaCoCo dump after each test case, preferably prefixed with test case name.

Without changing the existing test case source (i.e. can't use @AfterClass and other annotations), is it possible in TestNG and JUnit to run a script/program after each test case finishes?

The tool has to be generic. I have TestNG/JUnit test suite files triggered with Gradle build files. I want to let them run while JaCoCo agent is listening and as soon as each test finishes, I want to trigger the JaCoCo ant task to take the dump.

There are over 2000 tests so modifying them is out of question. I was thinking more along in terms of if TestNG and JUnit listeners can be extended to achieve this.

0 个答案:

没有答案