Skip to content
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

changed junit output fix #4919

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
10 changes: 9 additions & 1 deletion platformio/test/reports/junit.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from platformio import __version__
from platformio.test.reports.base import TestReportBase
from platformio.test.result import TestStatus
import xml.dom.minidom as minidom


class JunitTestReport(TestReportBase):
Expand All @@ -36,11 +37,18 @@ def generate(self, output_path, verbose=False):
)

with open(output_path, mode="wb") as fp:
self.build_xml_tree().write(fp, encoding="utf8")
xml_tree = self.build_xml_tree()
xml_str = ET.tostring(xml_tree.getroot(), encoding="utf8", method="xml")
pretty_xml_str = self.prettify_xml(xml_str)
fp.write(pretty_xml_str.encode("utf8"))

if verbose:
click.secho(f"Saved JUnit report to the {output_path}", fg="green")

def prettify_xml(self, xml_str):
parsed_xml = minidom.parseString(xml_str)
return parsed_xml.toprettyxml(indent="\t")

def build_xml_tree(self):
root = ET.Element("testsuites")
root.set("name", self.test_result.project_dir)
Expand Down