Skip to content

Latest commit

 

History

History
107 lines (78 loc) · 2.86 KB

File metadata and controls

107 lines (78 loc) · 2.86 KB

Add a link to a test case

There are two ways of adding a link to a test result:

  1. Using gherkin tags
  2. Dynamically in python code

Using gherkin tags to add a link

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.

Providing a link dynamically

You may also create a link dynamically and associate it with a test case in various places in your python code.

Example

Here we add two links dynamically: one from the before_scenario hook and another one from the step definition.

Feature file:

Feature: Allure link support
    Scenario: Issue from the step definition and link from the hook
        Given a link is associated with this test case

Steps definition file:

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"
    )

environment.py:

import allure

def before_scenario(context, scenario):
    allure.dynamic.link(
        "https://qameta.io/allure-report/",
        name="Allure Report"
    )