There are two ways of adding a link to a test result:
- Using gherkin tags
- Dynamically in python code
You can associate a link with a test by applying the
@allure.link.<name>:<URL>
tag to the scenario:
Feature: Allure link support
@allure.link.report:https://qameta.io/allure-report/
Scenario: Scenario with the link to the allure report website
Given noop
A link can also be associated with any scenario in a feature by applying the tag to the feature:
@allure.link.homepage:https://qameta.io
Feature: Allure link support
Scenario: Scenario with the link to the homepage
Given noop
Scenario: Another scenario with the link to the homepage
Given noop
A link to an issue or a test case can be added with @allure.issue:<URL>
and @allure.tms:<URL>
:
Feature: Allure link support
@allure.issue:https://github.com/allure-framework/allure-python/issues/1
Scenario: Scenario associated with the issue
Given noop
@allure.tms:https://qameta.io/#features
Scenario: Scenario associated with the TMS test case
Given noop
Please, note, that no whitespaces are allowed in a gherkin tag. Make sure your URLs are properly encoded.
You may also create a link dynamically and associate it with a test case in various places in your python code.
Here we add two links dynamically: one from the before_scenario
hook and
another one from the step definition.
Feature: Allure link support
Scenario: Issue from the step definition and link from the hook
Given a link is associated with this test case
import allure
from behave import given
@given("a link is associated with this test case")
def step_impl(context):
allure.dynamic.issue(
"https://github.com/allure-framework/allure-python/issues/1",
"Skip None and empty values in json"
)
import allure
def before_scenario(context, scenario):
allure.dynamic.link(
"https://qameta.io/allure-report/",
name="Allure Report"
)