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

Verification fails if root element is <testsuite> and <system-out> presents #111

Open
Hsilgos opened this issue Jul 26, 2023 · 3 comments · May be fixed by #142
Open

Verification fails if root element is <testsuite> and <system-out> presents #111

Hsilgos opened this issue Jul 26, 2023 · 3 comments · May be fixed by #142

Comments

@Hsilgos
Copy link

Hsilgos commented Jul 26, 2023

If root element is <testsuite> (not <testsuites>) and there is <system-out> (I think any other also will trigger the issue) then junitparser verify ... fails with

Traceback (most recent call last):
  File "/Users/.../Library/Python/3.9/bin/junitparser", line 8, in <module>
    sys.exit(main())
  File "/Users/.../Library/Python/3.9/lib/python/site-packages/junitparser/cli.py", line 100, in main
    return verify(
  File "/Users/.../Library/Python/3.9/lib/python/site-packages/junitparser/cli.py", line 33, in verify
    if not case.is_passed and not case.is_skipped:
AttributeError: 'SystemOut' object has no attribute 'is_passed'

Basically this is junit test report from cucumber test runner.
Simplest example to reproduce the issue:

<?xml version="1.0" encoding="UTF-8"?><testsuite tests="783" name="cucumber.runtime.formatter.JUnitFormatter" failures="0" skipped="0" time="1272.267746">
<testcase classname="Test functionality" name="Test name" time="0.641439">
<system-out><![CDATA[Some test.......................passed
]]></system-out>
</testcase>
</testsuite>
@themanifold
Copy link

themanifold commented Nov 27, 2024

The problem is that there is no official spec for JUnit XML (which is crazy). If you have a look at https://github.com/testmoapp/junitxml which is probably the most comprehensive unofficial documentation for JUnit XML, you'll see that sometimes tools create XML with <testsuite> at the top level. The comments in junitparser state that it supports both <testsuite> and <testsuits> but there's a bug which means that the parser has a bug somewhere.

I am getting this from an older version of pytest, which I will upgrade to one that has this fix: pytest-dev/pytest#5477

@EnricoMi
Copy link
Collaborator

JUnitParser mirrors the allowed JUnit XML schema. The root element can be a <testsuites> or a <testsuite>. So reading a file may return a JUnitXml instance (which reflects <testsuites>) or a TestSuite instance. Iterating over the former reflects iterating over <testsuite> elements, iterating over the latter reflects iterating over <testcase> instances. Only TestCase class provides the is_passed.

@EnricoMi
Copy link
Collaborator

See #142.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants