Skip to content

Allure report doesn't take in correct number of tests when using parametrized tests where tests parameters are duplicated #864

Open

Description

@qwertzy-antonio-godinho

Describe the Bug
Allure report doesn't take in correct number of tests when using parametrized tests where tests parameters are duplicated.

Steps to Reproduce

  1. Create a Python virtual env
  2. Install allure-pytest
  3. Create example tests to reproduce:

import pytest

@pytest.mark.parametrize(
'a, b',
[
(1, 1),
(1, 1)
]
)

def test_one(a, b):
assert a == b

  1. Run tests using pytest --clean-alluredir --alluredir=/tmp/allure-results
  2. Generate allure report allure generate /tmp/allure-results/ --clean --output /tmp/allure-results/allure-report --single-file
  3. Open Allure report

Expected Behaviour
The report is generated without errors and the report shows 2 tests.

Screenshots or Additional Context
Current version:
Image
pip freeze:
allure-pytest==2.14.2
allure-python-commons==2.14.2
attrs==25.3.0
iniconfig==2.1.0
packaging==25.0
pluggy==1.6.0
pytest==8.3.5

Version 2.9.44 (expected working result):
Image
pip freeze:
allure-pytest==2.9.44
allure-python-commons==2.9.44
attrs==25.3.0
iniconfig==2.1.0
packaging==25.0
pluggy==1.6.0
pytest==8.3.5
six==1.17.0

What Language are you using?
Python 3.11.12

What Framework/Allure Integration you are using?
Pytest

What version of Allure Integration you are using?
2.34.0

What version of Allure Report you are using?
Latest

Code of Conduct
I agree to follow this project's Code of Conduct

Activity

  1. delatrie commented on Jun 9, 2025

    @delatrie
    Contributor

    Hi, @qwertzy-antonio-godinho, thanks for opening the issue.

    Could you please clarify the use case behind having two identical sets of parameter values?

  2. qwertzy-antonio-godinho commented on Jun 11, 2025

    @qwertzy-antonio-godinho
    Author

    Hi, @delatrie, hope you're well. The use case is that at work we use maps for different "products" (which at a later stage diverge in characteristics), but to the point, the issue that I'm reporting is that newer allure versions do not report on the correct number of tests ran by pytest like in previous version 2.9.44.

    A better example of my use case would be something like:

    from enum import Enum
    import pytest
    
    class Products(Enum):
        PRODUCT_1 = 'PROD_1'
        PRODUCT_2 = 'PROD_2'
        PRODUCT_3 = 'PROD_1'
    
    @pytest.mark.parametrize(
        'a, b', 
        [    
            (Products.PRODUCT_1.value, 'PROD_1'), 
            (Products.PRODUCT_2.value, 'PROD_2'),
            (Products.PRODUCT_3.value, 'PROD_1'),
        ]
    )
    
    def test_one(a, b):
        assert a == b
    

    There are 3 tests, but unfortunately Allure only shows 2 in the report (in our test suite to misses close to 200 tests).

    Please see bellow:
    Image

    When there are failures, Allure also does not report the correct number of failed tests:

    Image

    I think the issue could probably be related to this one: #778

  3. sharovd commented on Jun 15, 2025

    @sharovd
    Contributor

    @delatrie, hi!
    I have investigated this issue and tried a few solutions, but none of them work in every known case 🙁
    Could you please take a look? Perhaps I’ve overlooked something, or maybe we could agree on a compromise.

    • To fix issue using pytest.mark.parametrize will miss some testcase in report #778, we could include the parameter name and value used to calculate the historyId. Currently, we only use the value. However, this change would not solve the problem described here.
    • Another option would be to use item.callspec.id to calculate the historyId. However, this would break the fix for Changing an id of a pytest parameter set breaks test's history #744, where only the parameter id changes. Perhaps we can consider stopping support for that scenario?
    • I also tried using the parameter index (item.callspec.indices), but if the order of the test data changes, the historyId will be different and we won't be able to match the same test in the history, which doesn't feel right.

    I’d be glad to hear any other ideas on how to solve this. I’m ready to finalize this work, prepare a PR, and update the tests. Thanks!

  4. HenriqueMagnagoTyphoon commented on Oct 22, 2025

    @HenriqueMagnagoTyphoon

    Is this a new behaviour? I am using different ids for different tests, and I do not recall having missing tests in the allure report. I have been using them for quite a while. This is a simplified version of the test I was running:

    import pytest
    from random import random as rd
    
    n = 100
    
    @pytest.mark.parametrize("val", [round(rd(), 1) for _ in range(n)], ids=[f'Case{x}' for x in range(n)])
    def test_foo(val):
        assert val < 0.5
    Image Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions