java - Detect test failure in testng @AfterMethod -
i want take screenshot if test fails. rather wrapping test methods try/catch blocks, add logic @aftermethod.
how can detect in @aftermethod if current test has failed?
if @aftermethod takes itestresult parameter testng automatically inject result of test. (source: testng documentation, section 5.18.1)
this should job:
@aftermethod public void teardown(itestresult result) { if (result.getstatus() == itestresult.failure) { //your screenshooting code goes here } }
Comments
Post a Comment