NoseXUnit: JUnit like XML reporting for PyUnit

NoseXUnit provide a convenient way to produce JUnit like XML reports with PyUnit. It also provides code coverage and audit features with beautiful reports generation.

News

NoseXUnit is now compatible with Nose 0.11.1. This version 0.3.3 is mainly a bug fix version. We also added a degraded mode to handle multiprocess test runner (--processes option in nose).

Backgroud

On the one hand, most of complex applications mix different languages and frameworks. On the other hand, test frameworks don't provide standard outputs. This makes difficult to generate an overall report of the tests for your aplication. However, some Java tests frameworks like JUnit with Surefire outputs convenient test report in a simple XML format. This makes further processing simple and convenient for softwares. For example, Hudson and Bamboo creates interesting reports thanks these XML reports.

Our goal is to provide a way to produce test reports in this simple XML format with PyUnit.

Install

NoseXUnit is a plugin for python-nose. Nose is a convenient way to play your PyUnit test.

Install NoseXUnit using setuptools:

easy_install NoseXUnit

NoseXUnit depends on:

Install of logilab-common, logilab-astng and pylint doesn't seem to work properly with setuptools. You may have to download them separately and install them with the old fashioned way before installing NoseXUnit.

Basic usage

Use the nosetests script with --with-nosexunit option:

nosetests --with-nosexunit [options] [(optional) test files or directories]

You can specify (all optionals):

PyLint usage

PyLint audit is enabled with --enable-audit option:

nosetests --with-nosexunit --source-folder=PATH --enable-audit [options] [(optional) test files or directories]

Source folder specification is required. All packages located in this source folder are analyzed. PyLint can't be used with code coverage.

You can specify (all optionals):

In source code, you can explicitely ignore an error uncovered by PyLint by using the following tag:

def foo():
    exec('a=1')
    print a      # pylint: disable-msg=E0602

Coverage usage

Code coverage is enabled with --enable-cover option:

nosetests --with-nosexunit --source-folder=PATH --enable-cover [options] [(optional) test files or directories]

Source folder specification is required. All packages located in this source folder are analyzed. Code coverage can't be used with PyLint.

You can specify (all optionals):

We also generate two extra reports in coverage target folder:

In source code, you can explicitely refuse code coverage with:

def foo():
    print "hello"      # pragma: no cover

Specify packages processed by Audit or Coverage

To explicitely specify packages processed by Audit or Coverage, you can use following options (all optionals):

Options --extra-include and --extra-exclude can be specified many times. For example:

nosetests [options] --extra-include foo1 --extra-include foo2

NoseXUnit Usage

NoseXUnit launch options can be display by running:

nosetests --help
Four options are available:
  --with-nosexunit      Enable plugin NoseXUnit: Output XML report of test
                        status [NOSE_WITH_NOSEXUNIT]
  --core-target=CORE_TARGET
                        Output folder for test reports (default is
                        target/NoseXUnit/core).
  --source-folder=SOURCE
                        Set source folder (optional for core functionality,
                        required for audit and coverage). Add folder in
                        sys.path.
  --search-source       Walk in the source folder to add deeper folders in
                        sys.path if they don't contain __init__.py file. Works
                        only if --source-folder is defined.
  --search-test         Search tests in folders with no __init__.py file
                        (default does nothing).
  --extra-include=EXTRA_INCLUDE
                        Include packages for audit or coverage processing
                        (default: take all packages in --source-folder, except
                        those defined in --extra-exclude).
  --extra-exclude=EXTRA_EXCLUDE
                        Exclude packages for audit or coverage processing
                        (default: ez_setup, setup). Useless if --extra-include
                        defined.
  --extra-test-process  Include packages matching the test pattern in audit or
                        coverage processing (default: no).
  --enable-audit        Use PyLint to audit source code (default: no)
  --audit-target=AUDIT_TARGET
                        Output folder for PyLint reports (default is
                        target/NoseXUnit/audit).
  --audit-output=AUDIT_OUTPUT
                        Output for audit reports: nosexunit, parseable, text,
                        colorized, html, msvs (default: nosexunit).
  --audit-config=AUDIT_CONFIG
                        Configuration file for PyLint (optional).
  --enable-cover        Use coverage to audit source code (default: no)
  --cover-target=COVER_TARGET
                        Output folder for coverage reports (default is
                        target/NoseXUnit/cover).
  --cover-clean         Clean previous coverage results (default: no).
  --cover-collect       Collect other coverage files potentially generated in
                        cover target folder. These extra files should have the
                        following pattern: .coverage.* (default: no).

Bug reports

Please report bugs and make feature requests here.

Changelog

0.3.3

0.3.2

0.3.1

0.3.0c1

0.2.0c1

0.2.0a1

0.1.0