Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/junitparser/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def verify(paths):
xml = JUnitXml.fromfile(path)
for suite in xml:
for case in suite:
if not case.is_passed and not case.is_skipped:
if case.is_failure or case.is_error:
return 1
return 0

Expand Down
22 changes: 22 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,28 @@ def test_verify(file: str, expected_exitcode: int):
assert cli.verify([path]) == expected_exitcode


@pytest.mark.parametrize(
"results, expected_exitcode",
[
("", 0),
("<skipped/>", 0),
("<failure/>", 1),
("<error/>", 1),
("<skipped/><failure/>", 1),
("<failure/><skipped/>", 1),
("<skipped/><error/>", 1),
("<error/><skipped/>", 1),
],
)
def test_verify_mixed_results(tmp_path, results, expected_exitcode):
path = tmp_path / "report.xml"
path.write_text(
f'<testsuite><testcase name="test">{results}</testcase></testsuite>'
)

assert cli.main(["verify", str(path)]) == expected_exitcode


def test_merge(tmp_path: Path):
files = [DATA_DIR / "jenkins.xml", DATA_DIR / "pytest_success.xml"]
suites = ["JUnitXmlReporter", "JUnitXmlReporter.constructor", "pytest"]
Expand Down