mercredi 25 avril 2018

How can I get TestNG ITestResult in Spring test listener?

I'm writing tests using Spring and TestNG. An example of a test class:

@SpringBootTest
@TestExecutionListeners(
        mergeMode = TestExecutionListeners.MergeMode.MERGE_WITH_DEFAULTS,
        listeners = {TestListener.class}
)
public class BaseTest extends AbstractTestNGSpringContextTests
{
}

My TestListener class extends TransactionalTestExecutionListener so I have override methods for beforeTestClass(TestContext testContext), afterTestMethod(TestContext testContext) etc.

My problem is that within afterTestMethod I need to be able to get the TestNG ITestResult or TestResult so I can do different things depending on test success, fail or skip etc. Is there any way I can access ITestResult or TestResult from a spring test listener?

Aucun commentaire:

Enregistrer un commentaire