change the status of a test result after it is exe

2019-05-29 14:57发布

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.

标签: testng
1条回答
虎瘦雄心在
2楼-- · 2019-05-29 15:03

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.

查看更多
登录 后发表回答