Open Alpherie opened 5 years ago
Any update?
Something news?
Any update? @sseliverstov
??
any progress??
@Alpherie @Ljancek @demetrissss @vishuhanda you can add a hook to the environment.py like this:
import allure
def after_scenario(context, scenario):
stdout = context.stdout_capture.getvalue()
stderr = context.stderr_capture.getvalue()
if stdout:
allure.attach(stdout, name="stdout", attachment_type=allure.attachment_type.TEXT)
if stderr:
allure.attach(stderr, name="stderr", attachment_type=allure.attachment_type.TEXT)
Please do not close this issue. Probably in the next versions I will add captured automaticaly
@sseliverstov thank you, it worked!
@Alpherie @Ljancek @demetrissss @vishuhanda you can add a hook to the environment.py like this:
import allure def after_scenario(context, scenario): stdout = context.stdout_capture.getvalue() stderr = context.stderr_capture.getvalue() if stdout: allure.attach(stdout, name="stdout", attachment_type=allure.attachment_type.TEXT) if stderr: allure.attach(stderr, name="stderr", attachment_type=allure.attachment_type.TEXT)
I don't seem to get this to work..
Where are these values set:
context.stdout_capture
context.stderr_capture
Are they just directly accessible through context
? I get an error when I copy this code directly:
HOOK-ERROR in after_scenario: AttributeError: 'NoneType' object has no attribute 'getvalue'
@eitel13 Are they just directly accessible through
context
? I get an error when I copy this code directly:
They should be. How are you launching behave? I use formatter
-f allure_behave.formatter:AllureFormatter
@Alpherie
How are you launching behave? I use formatter
I like to run tests with the IDE UI and unfortunately, there's things that just "don't work" with Behave and the IDE UI (eg: PyCharm Behave does not support "--junit" parameter).
I think this is one of them.
This is what the code looks like:
def after_scenario(context, scenario):
try:
stdout = context.stdout_capture.getvalue()
stderr = context.stderr_capture.getvalue()
print(f"stdout: {stdout}")
print(f"stderr: {stderr}")
if stdout:
allure.attach(
stdout,
name="stdout",
attachment_type=allure.attachment_type.TEXT,
)
if stderr:
allure.attach(
stderr,
name="stderr",
attachment_type=allure.attachment_type.TEXT,
)
except AttributeError:
print("No stdout/stderr captured")
else:
print("stdout/stderr captured")
If I run through terminal, then I get:
stdout:
stderr:
stdout/stderr captured
Running through UI, the AttributeError
is raised. 🙃
I'm submitting a ...
What is the current behavior?
Output from stdout and stderror is not captured for the report when using allure-behave.
What is the expected behavior?
Stdout and stderror output should be available when viewing Overview for the test.
What is the motivation / use case for changing the behavior?
To have an easy way to see the test-related output for future debugging/bug reporting/etc.
Please tell us about your environment: