Skip to content

Allure step in thread not show in report. #563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks
nigredon1991 opened this issue Feb 12, 2021 · 6 comments · Fixed by #647
Closed
2 tasks

Allure step in thread not show in report. #563

nigredon1991 opened this issue Feb 12, 2021 · 6 comments · Fixed by #647

Comments

@nigredon1991
Copy link

nigredon1991 commented Feb 12, 2021

I'm submitting a ...

  • [* ] 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?

Steps do not appear in the report if they were launched inside a thread.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

This example code for reproduce:

import allure
from concurrent.futures import ThreadPoolExecutor

@allure.step("lala")  
def lala(x=1):        
    print('run lala') 
                                
def test_lala():                                                                                  
    with ThreadPoolExecutor(max_workers=2) as executor: 
        executor.map(lala)                              

image

What is the expected behavior?

I would like the steps to appear in the report.

What is the motivation / use case for changing the behavior?

I need to run tests that execute commands remotely on multiple devices, so it's convenient to use threads, but the report does not contain steps declared inside the thread. Can you tell me if this can be done differently, or somehow forward the state to the parent thread.

Please tell us about your environment:

Other information

@bugsnub
Copy link

bugsnub commented Feb 15, 2021

even allure.attach when is running inside threads is not working.

See this sample code:

import pytest
import allure
import random
from concurrent.futures import ThreadPoolExecutor, as_completed
def test_01_allure_attach():
    def thread_function():
        body = str(random.random())
        allure.attach(body=body, name=body)

    with ThreadPoolExecutor(max_workers=5) as executor:
        thread_executor = {executor.submit(thread_function): x for x in range(0, 10)}
        for completed_thread in as_completed(thread_executor):
            iteration = thread_executor[completed_thread]
            print(iteration)
def test_02_allure_attach():
    for x in range(0, 10):
        body = str(random.random())
        allure.attach(body=body, name=body)

now when you generate allure report, 2nd test is showing attachments while 1st one is not showing.
ss-01
ss-02

@nikitapalta
Copy link

Is there a resolution to this problem? I am facing similar issue in my automation as well.

@nigredon1991
Copy link
Author

@nikitapalta, I solved this problem for myself here:

https://github.com/nigredon1991/allure-python/tree/allure_step_in_thread

You can try to test, maybe I will make a request.

@bugsnub
Copy link

bugsnub commented Jun 30, 2021 via email

@nigredon1991
Copy link
Author

nigredon1991 commented Jul 1, 2021

Created request #605.

@qingqingweiran
Copy link

@nigredon1991 is it support process?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants