Attachments not working for Configuration Methods using IInvokedMethodListener (Allure-TestNG
See original GitHub issueI’m submitting a …
- [X] bug report
- feature request
- support request => Please do not submit support request here, see note at the top of this template.
What is the current behavior?
Issue description:
- I’m implementing the
IInvokedMethodListener
for TestNG - Inside it I have Overridden the
afterInvocation
method - I use this to create a log for the current test method
Reporter.getOutput(testResult)
- Then I try to attach this log file using this code
Allure.addAttachment(attachmentDescription, "text/plain", attachmentContent, ".txt");
- This works as expected for all
@Test
methods, but it doesn’t work for configuration methods like@BeforeMethod
and@AfterMethod
- This error is shown in the console
[main] ERROR io.qameta.allure.AllureLifecycle - Could not add attachment: no test is running
Debugging Information
Upon debugging this issue I traced it to this method
String io.qameta.allure.AllureLifecycle.prepareAttachment(String name, String type, String fileExtension)
Apparently threadContext.getCurrent();
is returning empty instead of returning the UUID of the current configuration method.
This behavior is shown if I’m running any test, but if I’m debugging it becomes intermittent, and sometimes works as expected!!!
What is the expected behavior?
The attachment should be added successfully, and this error should not happen.
What is the motivation / use case for changing the behavior?
This impacts reporting attachments for any configuration method.
Please tell us about your environment:
| Test framework | testng@7.0.0 | | Allure integration | allure-testng@2.13.1 | | AspectJ Weaver | aspectjweaver | 1.9.5 | | Java run-time environment | JDK | 13 | | IDE | Eclipse | Build id: 20191212-1212 |
Other information
- I couldn’t downgrade to acpectj 1.8.0 because it’s not working with JDK 13
- Tried using a different listener ‘IConfigurationListener’ but the same issue persisted
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:16 (3 by maintainers)
Top GitHub Comments
I can suggest using Allure Lifecycle listeners like io.qameta.allure.listener.StepLifecycleListener or io.qameta.allure.listener.TestLifecycleListener
yeah, that’s because Allure is using the same API to process TestNG lifecycle events, and there is no guarantee in what order this hooks are executed. So basically if your hook goes first, you’ll see the attachment in the report, otherwise you’ll not.