allure-python icon indicating copy to clipboard operation
allure-python copied to clipboard

"Ids" of parametrized tests are not displayed in allure reports

Open eg-b opened this issue 4 years ago • 7 comments

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?

Allure doesn't display "ids" in reports

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

Write a parameterized test (@pytest.mark.parametrized) with multiple test data and "ids" params

screens:

allure_bug_code allure_bug_ids_in_cmd allure_bug_report

What is the expected behavior?

Allure report display test cases in format: "test_case_name [ids value]"

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

Please tell us about your environment:

Other information

eg-b avatar Oct 28 '20 13:10 eg-b

I think this workaround with "dynamic" title in test body it will help you

@pytest.mark.parametrize('input, id_value', [(1, 'int'), ('1', 'str')], ids=['int', 'str'])
def test_1(input, id_value):
	allure.dynamic.title(f'bla-bla [{id_value}]')
	with allure.step('test'):
		assert True

Quron avatar Oct 31 '20 14:10 Quron

I think this workaround with "dynamic" title in test body it will help you

@pytest.mark.parametrize('input, id_value', [(1, 'int'), ('1', 'str')], ids=['int', 'str'])
def test_1(input, id_value):
	allure.dynamic.title(f'bla-bla [{id_value}]')
	with allure.step('test'):
		assert True

thanks, but I understand correctly that the task I started is still a bug, or if I use allure.titles, then the only way to see ids next to them is to use a dynamic title?

eg-b avatar Nov 03 '20 09:11 eg-b

My opinion is not a bug, allure.title changes title as we specified.

Quron avatar Nov 03 '20 11:11 Quron

@eg-b you can do this

@pytest.mark.parametrize('id', [1, 2])
@allure.title('title with {id}')
def test_test(id):
    with allure.step('test step'):
        pass

and report will look like image

rad96 avatar Dec 04 '20 20:12 rad96

@rad96 thanks, but your option also suggests using test data in the title, instead of ids. The input parameter in the report is already visible on the right edge of the line. I was looking for an opportunity to use exactly ids

eg-b avatar Dec 04 '20 20:12 eg-b

@eg-b made PR for that change, need @sseliverstov to review and check if these changes necessary

rad96 avatar Dec 04 '20 23:12 rad96

@eg-b made PR for that change, need @sseliverstov to review and check if these changes necessary

was this pr cancelled after all? is there any other way to allow keeping the title defined in @allure.title() decorator, along with the parameter ids?

eldbud avatar Sep 22 '21 15:09 eldbud

Duplicate of #341 You can use the following workaround without the need to add an id as a parameter:

import allure
import pytest

@pytest.mark.parametrize("v", ["Value 1", "Value 2"], ids=["key-1", "key-2"])
def test_function(request, v):
    allure.dynamic.title(f"Test {request.node.callspec.id} <-")

delatrie avatar Dec 26 '22 12:12 delatrie