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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -