Allure report doesn't take in correct number of tests when using parametrized tests where tests parameters are duplicated
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
- Create a Python virtual env
- Install allure-pytest
- Create example tests to reproduce:
import pytest
@pytest.mark.parametrize(
'a, b',
[
(1, 1),
(1, 1)
]
)
def test_one(a, b): assert a == b
- Run tests using
pytest --clean-alluredir --alluredir=/tmp/allure-results - Generate allure report
allure generate /tmp/allure-results/ --clean --output /tmp/allure-results/allure-report --single-file - Open Allure report
Expected Behaviour The report is generated without errors and the report shows 2 tests.
Screenshots or Additional Context
Current version:
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):
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
Hi, @qwertzy-antonio-godinho, thanks for opening the issue.
Could you please clarify the use case behind having two identical sets of parameter values?
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:
When there are failures, Allure also does not report the correct number of failed tests:
I think the issue could probably be related to this one: https://github.com/allure-framework/allure-python/issues/778
@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 #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.idto calculate thehistoryId. However, this would break the fix for #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, thehistoryIdwill 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!
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