allure-framework / allure-framework/allure-python

allure-pytest: using the same @pytest.mark.parametrize for tests with different browsers appear as retries of the same test in the test report.

Open
#752 7 comments 1 reaction 0 assignees View on GitHub
bug contribute theme:pytest
Dominant language
Python
Stars
814
Forks
260
PR merge metrics
No merged PRs in 30d

Description

Hi, I am conducting login tests on different browsers using `pytest-playwright`. I am using `@pytest.mark.parametrize` to run tests with different emails and passwords. However, I noticed that in the allure report, my tests for Edge and Chrome are grouped together as the same test case. The test that runs first becomes the retries for the subsequent test case. I want them to appear as separate tests.

What I would want it to be like would be:
```
test_file_name
|__ Chrome
| |__ Test if the website can be successfully logged in
|
|__ Edge
| |__ Test if the website can be successfully logged in
|
|__ Firefox
| |__ Test if the website can be successfully logged in
```
I've tried using `allure.dynamic.tag` and `allure.dynamic.parameter`, but they didn't help. Thanks in advance.

#### I'm submitting a ...
- [ ] bug report
#### What is the current behavior?
![image](https://github.com/allure-framework/allure-python/assets/56353753/6138f0a8-4073-47d2-9bcd-d92644a597b7)

#### If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
test_login.py
```
login_correct=[{"email": "123", "password": "123"}]

@allure.story("Test if the website can be successfully logged in")
@allure.title("{test_input}")
@allure.description("Enter the website and input correct email and password to check if can login.")
@pytest.mark.parametrize("test_input",login_correct)
def test_login_success(setup,test_input):
page = setup
login(page, test_input["email"], test_input["password"])
expect(page.get_by_text("Dashboard").first).to_be_visible(timeout=50*1000)
```

conftest.py
```
@pytest.fixture(scope="function")
def setup(page: Page,pytestconfig):
page.set_viewport_size({"width": 1920, "height": 1080})
page.goto(".....")

browser = pytestconfig.getoption("--browser")
browser_channel = pytestconfig.getoption("--browser-channel")
if browser_channel != None:
allure.dynamic.feature(f"{browser_channel}")
allure.dynamic.tag(browser_channel)
allure.dynamic.parameter("browser_name",browser_channel)
else:
allure.dynamic.feature(f"{browser[0]}")
allure.dynamic.tag(browser[0])
allure.dynamic.parameter("browser_name",browser[0])
yield page
```
I am testing different browsers using the following command:
```
pytest -n auto --browser-channel=chrome --alluredir=allure-results
pytest -n auto --browser=firefox --alluredir=allure-results
pytest -n auto --browser-channel=msedge --alluredir=allure-results
```

#### What is the expected behavior?
The Edge test case and Chrome Test case need to be seperate.

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

#### Please tell us about your environment:

- Allure version: 2.22.3
- Test framework: pytest@7.3.2
- Allure adaptor: allure-pytest@2.13.2
- pytest-playwright 0.3.3

Contributor guide

Open the contributing guide

Research direction

Start with the provided test_login.py and conftest.py, then reproduce the report using the three pytest commands for Chrome, Firefox, and Edge. Compare how the generated Allure results identify each browser run; done means the report shows separate test cases for each browser rather than retries.

Written by the indexing model from the issue text.

Assessment

Tech stack
playwright, python
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.