change the status of a test result after it is exe

2019-05-29 14:39发布

问题:

Is it possible to change the status of a test result from @AfterClass method. My requirement is to run some UI tests using @test tag and I need to validate the DB for all those tests in the @AfterClass method, since the DB is taking a while to get updated.

回答1:

You cannot do it in AfterClass, but you can utilize a listener to do this. Try out IInvokedMethodListener. Implement the following method : public void afterInvocation(IInvokedMethod method, ITestResult testResult)

The result object can be set here to whatever value, based on some checks (testResult.setStatus(status)). Note this would be executed after every method.



标签: testng