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

implement flavors #108

Merged
merged 12 commits into from
Apr 24, 2023
Merged
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [3.1.0] - 2023-04-22
### Added
- Support for different schemas.
- xunit2 flavor support
- Type hints

## [3.0.0] - 2023-04-20
### Breaking
Python 2 is no longer supported. Version 2.x will keep supporting py2 and it will be maintained as long as possible, though no new features will be added.
Expand Down
33 changes: 33 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,39 @@ You have two or more XML files, and you want to merge them into one.
Note that it won't check for duplicate entries. You need to deal with them on
your own.

Schema Support
~~~~~~~~~~~~~~~

By default junitparser supports the schema of windyroad_, which is a relatively
simple schema.

.. _windyroad: https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd

Junitparser also support extra schemas:

.. code-block:: python

from junitparser.xunit2 import JUnitParser, TestCase, TestSuite, \
RerunFailure
# These classes are redefined to support extra properties and attributes
# of the xunit2 schema.
suite = TestSuite("mySuite")
suite.system_err = "System err" # xunit2 specific property
case = TestCase("myCase")
rerun_failure = RerunFailure("Not found", "404") # case property
rerun_failure.stack_trace = "Stack"
rerun_failure.system_err = "E404"
rerun_failure.system_out = "NOT FOUND"
case.add_rerun_result(rerun_failure)

Currently supported schemas including:

- xunit2_, supported by pytest, Erlang/OTP, Maven Surefire, CppTest, etc.

.. _xunit2: https://github.com/jenkinsci/xunit-plugin/blob/xunit-2.3.2/src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd/junit-10.xsd

PRs are welcome to support more schemas.

Create XML with custom attributes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion junitparser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
FloatAttr,
)

version = "3.0.0"
version = "3.1.0"
7 changes: 5 additions & 2 deletions junitparser/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def _parser(prog_name=None): # pragma: no cover

# command: verify
merge_parser = command_parser.add_parser(
"verify", help="Return a non-zero exit code if one of the testcases failed or errored."
"verify",
help="Return a non-zero exit code if one of the testcases failed or errored.",
)
merge_parser.add_argument(
"--glob",
Expand All @@ -74,7 +75,9 @@ def _parser(prog_name=None): # pragma: no cover
action="store_true",
default=False,
)
merge_parser.add_argument("paths", nargs="+", help="XML path(s) of reports to verify.")
merge_parser.add_argument(
"paths", nargs="+", help="XML path(s) of reports to verify."
)

return parser

Expand Down
Loading