Skip to content

Conversation

@oatssss
Copy link
Contributor

@oatssss oatssss commented Mar 17, 2021

Context

Hardcoded link tags in .features don't allow for dynamically adding links to the report. The dynamic use-case can be addressed with allure.dynamic.link(), however it appears to be a no-op for allure-behave. This PR adds the missing add_link hook to the behave listener.

With these changes, in addition to:

@allure.issue:https://jira.example.com/JIRA-1234
Scenario: Scenario with passed step
    Given simple passed step

we can also do:

import allure

def before_scenario(context, scenario):
    allure.dynamic.issue("https://jira.example.com/JIRA-1234", "JIRA-1234")

I used the pytest implementation as a reference for these changes:

@allure_commons.hookimpl
def add_link(self, url, link_type, name):
test_result = self.allure_logger.get_test(None)
if test_result:
pattern = dict(self.config.option.allure_link_pattern).get(link_type, u'{}')
link_url = pattern.format(url)
new_link = Link(link_type, link_url, link_url if name is None else name)
for link in test_result.links:
if link.url == new_link.url:
return
test_result.links.append(new_link)

Checklist

@oatssss
Copy link
Contributor Author

oatssss commented Mar 17, 2021

There are no changes to allure-robotframework I suspect the check-errors are not related to my changes.

@oatssss oatssss changed the title Support Dynamic.link for allure-behave Support Dynamic.link and Dynamic.description for allure-behave Mar 18, 2021
@sseliverstov sseliverstov merged commit 61da8af into allure-framework:master Mar 22, 2021
beckerGil pushed a commit to beckerGil/allure-python that referenced this pull request Apr 10, 2023
IvanBuruyane pushed a commit to IvanBuruyane/allure-python that referenced this pull request Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants