NoseXUnit: JUnit like XML reporting for PyUnit
NoseXUnit provide a convenient way to produce JUnit like XML reports with PyUnit.
News
NoseXUnit is now compatible with Nose 0.10.4. We also included optional PyLint and Coverage report generation.
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, 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:
- nose,
- pylint, logilab-common and logilab-astng to check the code,
- coverage for code coverage,
- kid and pygments for reports generations.
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):
- The XML output folder with --core-target=PATH,
- The folder containing the Python sources with --source-folder=PATH,
- If you want to recursively search source files in source folder to add them in the path with --search-source,
- If you want to recursively search tests that are located outside a package with --search-test,
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):
- The output folder for report with --audit-target=PATH,
- The type of output with --audit-output=TYPE: nosexunit, html, ... ,
- A PyLint configuration file with --audit-config=PATH.
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):
- The output folder for report with --cover-target=PATH,
- If you want to ignore previous executions for coverage with --cover-clean,
- If you want to collect extra coverage files with --cover-collect. These extra coverage files should be generated in the coverage target folder and have the follwing pattern: .coverage.*.
We also generate two extra reports in coverage target folder:
- A Clover style XML report: clover.xml,
- A Cobertura style XML report: cobertura.xml.
In source code, you can explicitely refuse code coverage with:
def foo():
print "hello" # pragma: no cover
NoseXUnit Usage
NoseXUnit launch options can be display by running:
nosetests --helpFour 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).
--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.1
- Generate a Clover style XML report,
- Generate a Cobertura style XML report,
- Add --cover-collect to collect extra coverage file.
0.3.0c1
- Compatibility with nose 0.10.4,
- PyLint reporting,
- Coverage reporting,
- ID 2078051: Support ContextSuite object with no id attribute in Plugin.startTest,
- Option --xml-report-folder replaced by --core-target,
- Option --recursive replaced by --search-source.
0.2.0c1
- Compatibility with nose 0.10.0a2,
- tb_info and capt removed from XTest (no more available with nose),
- Signature of addSuccess, addFailure and addError modified,
- Entry point modification.
0.2.0a1
- Compatibility with nose 0.10.0a1,
- Create an XML output for each test module.
0.1.0
- First version.