Skip to content

Commit 338262c

Browse files
authored
added dynamic links for robotframework (via #489)
1 parent dddd28f commit 338262c

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Dynamic Links
2+
-----
3+
4+
.. code:: robotframework
5+
6+
*** Test Cases ***
7+
Test Case With Dynamic Link
8+
Evaluate allure.dynamic.issue('https://jira.com/browse/ISSUE-1', 'ISSUE-1')
9+
... modules=allure
10+
Evaluate allure.dynamic.testcase('https://testrail.com/browse/TEST-1', 'TEST-1')
11+
... modules=allure
12+
Evaluate allure.dynamic.link('https://homepage.com/', name='homepage')
13+
... modules=allure

allure-robotframework/src/listener/allure_listener.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from allure_commons.utils import platform_label
1111
from allure_commons.utils import host_tag
1212
from allure_commons.utils import format_exception, format_traceback
13-
from allure_commons.model2 import Label
13+
from allure_commons.model2 import Label, Link
1414
from allure_commons.model2 import Status, StatusDetails
1515
from allure_commons.model2 import Parameter
1616
from allure_commons.types import LabelType, AttachmentType, Severity, LinkType
@@ -210,6 +210,13 @@ def add_label(self, label_type, labels):
210210
for label in labels if case else ():
211211
case.labels.append(Label(label_type, label))
212212

213+
@allure_commons.hookimpl
214+
def add_link(self, url, link_type, name):
215+
with self.lifecycle.update_test_case() as case:
216+
link = Link(url=url, type=link_type, name=name)
217+
if case and link not in case.links:
218+
case.links.append(Link(url=url, type=link_type, name=name))
219+
213220
@allure_commons.hookimpl
214221
def attach_data(self, body, name, attachment_type, extension):
215222
self.lifecycle.attach_data(uuid4(), body, name=name, attachment_type=attachment_type, extension=extension)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
*** Settings ***
2+
Library ../run_robot_library.py
3+
Library ../test_allure_library.py
4+
Suite Setup Run test case with dynamic link
5+
6+
7+
*** Keywords ***
8+
Run test case with dynamic link
9+
${allure_report} Run Robot With Allure examples/link/dynamic_link.rst
10+
${test_case} Should Has Test Case ${allure_report} Test Case With Dynamic Link
11+
Set Suite Variable ${test_case}
12+
13+
14+
*** Test Case ***
15+
Test Case With Dynamic Links
16+
${test case} Should Has issue To https://jira.com/browse/ISSUE-1 With Name ISSUE-1
17+
${test case} Should Has test_case To https://testrail.com/browse/TEST-1 With Name TEST-1
18+
${test case} Should Has link To https://homepage.com/ With Name homepage
19+
20+
*** Keywords ***
21+
${test case} Should Has ${link type} To ${url} With Name ${name}
22+
Should Has Link ${test_case} ${url} ${link type} ${name}

0 commit comments

Comments
 (0)