On my project I have maven and TestNG tools. And I'm trying to add screenshots to Allure reports. If I call the method with "@Attachment" annotation directly from my tests, everything is okay.
But if I call it in "@AfterMethod" part, the screenshots are added to wrong reports and are mixed up.
In both cases screenshots are generated and saved on the disk correctly.
I've already seen the question here: Allure Framework: TestNG adapter incorrectly places @AfterMethod in report
And I guess, my difficulties might be because of TestNG adaptor.
What is the correct way of calling the "@Attachment" method? What adaptor do I have to use in order to avoid this problem? Maybe someone could provide me with example of using ITestListener to make screenshots only if a test is failed?