Search code examples
testingtestngsoftware-quality

How to detect build after all tests are completely run using testNG?


There are several tests included in one build. There may be multiple classes with multiple tests for the same build. We use automated results publishing methodology and for that we need to identify when all the tests related to the corresponding build have been completely executed. I just want to clarify if there is a way to do this using TestNG?

I expect the solution is suitable for parallel execution also.


Solution

  • Build tool uses phases (Maven) /tasks (Gradle) to run tests. So you should be able to add an extra step in your build setup to help you do this.

    If you would like to have TestNG process reports, you could do one of the following:

    • Build an implementation of org.testng.IReporter and within this have your reports published. This interface implementation gets called by TestNG during the reporting phase after all the suites have been executed.
    • Build an implementation of org.testng.IExecutionListener and within this have your reports (that were already generated) be published. This listener implementation will be invoked by TestNG just before the execution commences and just about when its going to finish execution (but after the reporting phase)