allure-framework / allure-python

Allure integrations for Python test frameworks
https://allurereport.org/
Apache License 2.0
725 stars 237 forks source link

How to pass link from @pytest.mark.parametrize to @allure.link? #656

Closed vladyslavstetsenko closed 2 years ago

vladyslavstetsenko commented 2 years ago

Hello fellas, My current stack is Pytest + Selenium and Allure for reporting. I got the variables from @pytest.mark.parametrize and tried to pass it into allure decorators. In a case of @allure.title it works fine, but when I tried to pass link to @allure.link or @allure.testcase the value - actual link didn't appear in allure-report and the label as well (second parameter of @allure.testcase). And instead, I got {link} in Link section. If someone come across this issue, please let me know. This issue has been double-checked on https://github.com/allure-examples as well. image image

vladyslavstetsenko commented 2 years ago

Any updates on this?

vladyslavstetsenko commented 2 years ago

Any updates on this?

Ljancek commented 2 years ago

you can try @allure.link(f"{test_param}")

skhomuti commented 2 years ago

hey @vladyslavstetsenko you can do it with the following ways:

@pytest.mark.parametrize("test_link",
                         [pytest.param("https://example.com",
                                       marks=pytest.mark.allure_link("https://example.com",
                                                                     name='example',
                                                                     link_type='link'))]
                         )
def test_link_by_param(test_link):
    pass

@pytest.mark.parametrize("test_link",
                         [pytest.param("https://example.com")]
                         )
def test_link_by_dynamic(test_link):
    allure.dynamic.link(test_link)

@pytest.fixture()
def test_link_fixture(request):
    allure.dynamic.link(request.param)
    return request.param

@pytest.mark.parametrize("test_link_fixture",
                         [pytest.param("https://example.com")],
                         indirect=True)
def test_link_by_fixture(test_link_fixture):
    pass