Skip to content

Commit

Permalink
Merge branch 'mr/boris/junit-classname' into 'master'
Browse files Browse the repository at this point in the history
Log testsuite information into each testcase

See merge request it/e3-testsuite!27
  • Loading branch information
pmderodat committed May 14, 2024
2 parents b9f2de3 + 6df7c1a commit c06b501
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

* `e3-convert-xunit`: warn about dangling XFAILs annotations.
* `DiffTestDriver`: tolerate missing baseline files when rewriting baselines.
* The `--xunit-name` argument of `e3-testsuite-report` is now used to
fill the `classname` information of each XUnit individual test report.

26.0 (2023-01-19)
=================
Expand Down
10 changes: 3 additions & 7 deletions src/e3/testsuite/report/xunit.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,9 @@ def dump_xunit_report(name: str, index: ReportIndex, filename: str) -> None:
for test_name, entry in sorted(index.entries.items()):
result = entry.load()

# The only class involved in testcases (that we know of in this
# testsuite framework) is the TestDriver subclass, but this is not
# useful for the report, so leave this dummy "e3-testsuite-driver"
# instead.
testcase = etree.Element(
"testcase", name=test_name, classname="e3-testsuite-driver"
)
# We use the testsuite name for 'classname', as we don't really have
# something more useful to display anyway.
testcase = etree.Element("testcase", name=test_name, classname=name)
testsuite.append(testcase)

# Get the XUnit-equivalent status for this test and update the
Expand Down
35 changes: 35 additions & 0 deletions tests/tests/test_report_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,41 @@ def test_xunit_output(tmp_path, capsys):
ET.parse(xunit_file)


def test_xunit_name(tmp_path, capsys):
"""Check that --xunit-name has the desired effect."""
xunit_file = str(tmp_path / "xunit.xml")
testsuite_name = "mytestsuite"
run(
[create_result("foo", Status.PASS)],
[
"--xunit-output",
xunit_file,
"--xunit-name",
testsuite_name,
str(tmp_path),
],
tmp_path,
capsys,
)

xml = ET.parse(xunit_file)
root = xml.getroot()

# Check the root node
assert root.tag == "testsuites"
assert root.get("name") == testsuite_name

# Check the invididual testsuites
testsuites = xml.findall(".//testsuite")
assert len(testsuites) != 0
assert all(e.get("name") == testsuite_name for e in testsuites)

# Check the invidiual tests
tests = xml.findall(".//testcase")
assert len(tests) != 0
assert all(e.get("classname") == testsuite_name for e in tests)


def test_output_file(tmp_path, capsys):
"""Check that nothing is printed on stdout when output is a file."""
create_report(
Expand Down

0 comments on commit c06b501

Please sign in to comment.