Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions allure-robotframework/examples/link/dynamic_link.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Dynamic Links
-----

.. code:: robotframework

*** Test Cases ***
Test Case With Dynamic Link
Evaluate allure.dynamic.issue('https://jira.com/browse/ISSUE-1', 'ISSUE-1')
... modules=allure
Evaluate allure.dynamic.testcase('https://testrail.com/browse/TEST-1', 'TEST-1')
... modules=allure
Evaluate allure.dynamic.link('https://homepage.com/', name='homepage')
... modules=allure
9 changes: 8 additions & 1 deletion allure-robotframework/src/listener/allure_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from allure_commons.utils import platform_label
from allure_commons.utils import host_tag
from allure_commons.utils import format_exception, format_traceback
from allure_commons.model2 import Label
from allure_commons.model2 import Label, Link
from allure_commons.model2 import Status, StatusDetails
from allure_commons.model2 import Parameter
from allure_commons.types import LabelType, AttachmentType, Severity, LinkType
Expand Down Expand Up @@ -210,6 +210,13 @@ def add_label(self, label_type, labels):
for label in labels if case else ():
case.labels.append(Label(label_type, label))

@allure_commons.hookimpl
def add_link(self, url, link_type, name):
with self.lifecycle.update_test_case() as case:
link = Link(url=url, type=link_type, name=name)
if case and link not in case.links:
case.links.append(Link(url=url, type=link_type, name=name))

@allure_commons.hookimpl
def attach_data(self, body, name, attachment_type, extension):
self.lifecycle.attach_data(uuid4(), body, name=name, attachment_type=attachment_type, extension=extension)
Expand Down
22 changes: 22 additions & 0 deletions allure-robotframework/test/link/dynamic_link.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
*** Settings ***
Library ../run_robot_library.py
Library ../test_allure_library.py
Suite Setup Run test case with dynamic link


*** Keywords ***
Run test case with dynamic link
${allure_report} Run Robot With Allure examples/link/dynamic_link.rst
${test_case} Should Has Test Case ${allure_report} Test Case With Dynamic Link
Set Suite Variable ${test_case}


*** Test Case ***
Test Case With Dynamic Links
${test case} Should Has issue To https://jira.com/browse/ISSUE-1 With Name ISSUE-1
${test case} Should Has test_case To https://testrail.com/browse/TEST-1 With Name TEST-1
${test case} Should Has link To https://homepage.com/ With Name homepage

*** Keywords ***
${test case} Should Has ${link type} To ${url} With Name ${name}
Should Has Link ${test_case} ${url} ${link type} ${name}