Cannot take screenshot when run in parallel.
Hello,
I still cannot take screenshot, the problem is the ScreenshotPublisher doesn't executed, could you suggest? My current java-jbehave-allure project, I cannot when running in parallel.
BTW, I created resources->META-INF->services under src folder, and create a file named io.qameta.allure.listener.StepLifecycleListener, but seems it was not called during running.
Hey - I have released the framework as an open source project that we use internally. We fixed this issue by changing the stage at which the screenshots were pushed to be at the "afterStepUpdate" method.
The project is here: (documentation need improving!) https://gitlab.developers.cam.ac.uk/jsa34/selenium-java-framework
Hope this helps!
Originally posted by @jsa34 in https://github.com/allure-framework/allure-java/issues/285#issuecomment-486242962
Hi @jsa34, thanks for your comments.
I use allure2 for java/jbehave to attach screenshot to allure report, but unfortunately when running in multi thread, it says "[ERROR] Could not add attachment: no test is running" all the time, the screenshot is captured, but cannot attached to allure report correctly.
However, when running in one thread, everything is good.
I analyzed it and found Allure.addAttachment take screenshot correctly, but cannot attach to the all report, that is root cause. Do you know why, could you suggest?
Allure uses inheritable thread local to store test execution context (that later persists to file system as Allure Results) and in order to make it work it requires that threads used for scenario execution to be children of reporter thread.
Some test frameworks execute hooks that Allure uses to catch scenario start/stop events in same thread pool that used to execute scenarios itself. In that case Allure can't locate execution context to attach runtime data such as attachments (and you will see the warning you mentioned).
You can check it out by logging threads names from custom Reporter & test. If I'm right and scenario is executed in same thread poll as reporter there is nothing Allure can do -- the issue should be solved by framework (JBehave in your case).