Skip to main content

PyJUnitXML, a pyunit extension to output JUnit compatible XML.

Project description

A Python unittest TestResult that outputs JUnit compatible XML.

Usage

To use PyJUnitXML you need to specify it as your TestResult when running your tests using pyunit. One way of doing this is to invoke the test method directly on your test suite:

>>> import junitxml
>>> result = junitxml.JUnitXmlResult(sys.stdout)
>>> result.startTestRun()
>>> suite.run(result)
>>> result.stopTestRun()

The startTestRun and stopTestRun methods are new in python 2.7 and 3.1. If you are using older versions of python, and do not invoke the test result directly, you may find that no output occurs at all. This is likely because the stopTestRun method is not being invoked, and you will need to arrange for it to be invoked.

There is a command line runner you can use:

$ python -m junitxml.main discover

or

$ junitxml discover

If the package scripts have been installed.

Troubleshooting

My test runs, but nothing is output? Check that result.stopTestRun is being called. Due to the XML file format requiring a header containing the test counts, nothing is output until the test run has completed, and that is signalled by the stopTestRun method being called.

Reporting Bugs and Asking Questions

PyJUnitXML is hosted on Launchpad at https://launchpad.net/pyjunitxml. Please file bugs, ask questions and so on at will.

Running PyJUnitXML’s test suite

The function junitxml.test_suite defines the junitxml test suite, you can use any runner you like. I personally use:

$ python -m subunit.run junitxml.test_suite | subunit2gtk

If you have testrepository you can simply run testr:

$ testr run

Enjoy, Rob Collins

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

junitxml-0.7.tar.gz (26.0 kB view details)

Uploaded Source

File details

Details for the file junitxml-0.7.tar.gz.

File metadata

  • Download URL: junitxml-0.7.tar.gz
  • Upload date:
  • Size: 26.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for junitxml-0.7.tar.gz
Algorithm Hash digest
SHA256 a5901127067ab7f3d11df30727368c129c69b3f5595c697daf4f5ed80b1baaa3
MD5 20d17c015fc11781f9d30bf89b862590
BLAKE2b-256 86dfbdf6f8d13a62b7e70fe16f93158fef72322d74d771438ae5b5931f2d33b1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page