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.