Skip to content

QE-3461 :Embed html and page source into Allure Reports on Failure and perform Enhancement #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
13 changes: 12 additions & 1 deletion xmlrunner/allure_report/listener.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import os
import shutil

import allure_commons
from allure_commons.utils import host_tag, thread_tag
from allure_commons.utils import md5
Expand Down Expand Up @@ -41,6 +44,10 @@ def add_failure(self, test, err, info_traceback, message="The test is failed"):
if check_screenshot_exist(screenshot_name):
test_case.attachments.append(
Attachment(name=screenshot_name, source=f"{screenshot_name}.png", type="image/png"))
test_case.attachments.append(
Attachment(name=f"{screenshot_name}.xml", source=f"{screenshot_name}.xml", type="text/plain"))
test_case.attachments.append(
Attachment(name=f"{self.file_name}.html", source=f"{self.file_name}.html", type="text/plain"))
test_case.statusDetails = StatusDetails(message=message, trace=info_traceback)
test_case.status = Status.FAILED
self.reporter.schedule_test(self.current_test_uuid, test_case)
Expand All @@ -53,6 +60,10 @@ def add_error(self, test, err, info_traceback, message="The test is error"):
if check_screenshot_exist(screenshot_name):
test_case.attachments.append(
Attachment(name=screenshot_name, source=f"{screenshot_name}.png", type="image/png"))
test_case.attachments.append(
Attachment(name=f"{screenshot_name}.xml", source=f"{screenshot_name}.xml", type="text/plain"))
test_case.attachments.append(
Attachment(name=f"{self.file_name}.html", source=f"{self.file_name}.html", type="text/plain"))
test_case.statusDetails = StatusDetails(message=message, trace=info_traceback)
test_case.status = Status.BROKEN
if get_test_name(test) == "setUpClass":
Expand Down Expand Up @@ -111,4 +122,4 @@ def attach_file(self, source, name, attachment_type, extension):
@allure_commons.hookimpl
def add_link(self, url, link_type, name):
test_case = self.reporter.get_test(None)
test_case.links.append(Link(link_type, url, name))
test_case.links.append(Link(link_type, url, name))
22 changes: 21 additions & 1 deletion xmlrunner/allure_report/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,31 @@ def check_screenshot_exist(screenshot_name):
:return: True (if the file is existed in the screenshot folder) False (if the file doesn't exist)

"""
screenshot_path = posixpath.join("test-reports","screenshots", screenshot_name + ".png")
screenshot_path = posixpath.join("test-reports", "screenshots", screenshot_name + ".png")
if os.path.isfile(screenshot_path):
return True
return False

def check_screenshot_exist(screenshot_name):
""" Copy the log file from logs folder to specific test suite.

:param screenshot_name: screenshot name which matches with the current screenshot file in the screenshot folders.
:return: True (if the file is existed in the screenshot folder) False (if the file doesn't exist)

"""
screenshot_path = posixpath.join("test-reports", "screenshots", screenshot_name + ".png")
if os.path.isfile(screenshot_path):
return True
return False
def check_xml_exists(xml_path):
"""

"""
xml_path = posixpath.join("test-reports", "screenshots", xml_path + ".png")
if os.path.isfile(xml_path):
return True
return False


def copy_log_file(test_name, domain_name):
""" Copy the log file from logs folder to specific test suite.
Expand Down