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.
- 主要语言
- Python
- 星标
- 814
- 派生
- 260
- PR 合并指标
- 30 天内没有已合并 PR
描述
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?

#### 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
贡献指南
调研方向
从提供的 test_login.py 和 conftest.py 开始,然后使用针对 Chrome、Firefox 和 Edge 的三个 pytest 命令重现报告。比较生成的 Allure 结果如何识别每次浏览器运行;当报告显示每个浏览器对应的独立测试用例,而不是重试时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- playwright, python
- 领域
- testing-qa
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100