/python-junit-xml

A Python module for creating JUnit XML test result documents that can be read by tools such as Jenkins. If you are ever working with test tool or test suite written in Python and want to take advantage of Jenkins' pretty graphs and test reporting capabilities, this module will let you generate the XML test reports.

Primary LanguagePythonMIT LicenseMIT

python-junit-xml

image

About

A Python module for creating JUnit XML test result documents that can be read by tools such as Jenkins or Bamboo. If you are ever working with test tool or test suite written in Python and want to take advantage of Jenkins' or Bamboo's pretty graphs and test reporting capabilities, this module will let you generate the XML test reports.

As there is no definitive Jenkins JUnit XSD that I could find, the XML documents created by this module support a schema based on Google searches and the Jenkins JUnit XML reader source code. File a bug if something doesn't work like you expect it to. For Bamboo situation is the same.

Installation

Install using pip or easy_install:

pip install junit-xml
or
easy_install junit-xml

You can also clone the Git repository from Github and install it manually:

git clone https://github.com/kyrus/python-junit-xml.git
python setup.py install

Using

Create a test suite, add a test case, and print it to the screen:

Produces the following output

Writing XML to a file:

See the docs and unit tests for more examples.

NOTE: Unicode characters identified as "illegal or discouraged" are automatically stripped from the XML string or file.

Running the tests

# activate your virtualenv
pip install tox
tox

Releasing a new version

  1. Bump version in setup.py
  2. Build distribution with python setup.py sdist bdist_wheel
  3. Upload to Pypi with twine upload dist/*
  4. Verify the new version was uploaded at https://pypi.org/project/junit-xml/#history