Closed QAthulhu closed 4 years ago
@QAthulhu You should be able to use your custom @AfterMethod
to get access to the test and attach screenshots to it. Example:
@AfterMethod
public synchronized void afterMethod(ITestResult result) throws IOException {
switch (result.getStatus()) {
case ITestResult.FAILURE:
ExtentTestManager.getTest(result).fail("ITestResult.FAILURE, event afterMethod",
MediaEntityBuilder.createScreenCaptureFromPath(getImagePath()).build());
break;
case ITestResult.SKIP:
ExtentTestManager.getTest(result).skip("ITestResult.SKIP, event afterMethod");
break;
default:
break;
}
}
But won't I have to copy-paste this code into every @AfterMethod I use? Is there a way to set it somewhere else?
Absolutely not, only in your base/parent class.
It would be nice to be able to extend the testNG adapter to add screenshot on failure and logging of test steps. Out of the box it looks great, but only shows a Pass and Fail for each method.