Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python nose xunit report file is empty

I have a problem running nose tests and get results inside Jenkins.

The job has a shell script like this:

. /var/lib/jenkins/envs/itravel/bin/activate
python api/manage.py syncdb --noinput
DJANGO_SETTINGS_MODULE=ci_settings nosetests --verbosity=0 --processes=1 --with-xunit --xunit-file=nosetests.xml
deactivate

Part of the test suite is run using the django_nose.NoseTestSuiteRunner.

All the tests are run and the resulting nosetests.xml file is created but does not seem to be filled with the tests results:

<?xml version="1.0" encoding="UTF-8"?><testsuite name="nosetests" tests="0" errors="0" failures="0" skip="0"></testsuite>

I noticed that on an import Error fail the file is filled with one error, but otherwise, nothing...

Any idea? Is there something special to do from the tests side? Any property to set or so?

Thanks.

like image 256
Arnaud Avatar asked Apr 12 '12 09:04

Arnaud


People also ask

What is the use of xUnit output XML?

Xunit: output test results in xunit format¶. This plugin provides test results in the standard XUnit XML format. It’s designed for the Jenkins (previously Hudson) continuous build system, but will probably work for anything else that understands an XUnit-formatted XML representation of test results.

What is default test suite name in xUnit?

Default test suite name is nosetests. Whether to prefix the class name under test with testsuite name. Defaults to false. This plugin provides test results in the standard XUnit XML format.

Why use nose instead of unittest in Python?

Python’s standard unittest module loses ground to other Python test automation frameworks, as it requires a lot of boilerplate code and tests have to be included into large test classes. Nose is a popular alternative if you still want to use the default Python unit testing framework.

What is this xUnit plugin for Jenkins?

This plugin provides test results in the standard XUnit XML format. It’s designed for the Jenkins (previously Hudson) continuous build system, but will probably work for anything else that understands an XUnit-formatted XML representation of test results.


2 Answers

As far as I know, the --processes option is not compatible with --with-xunit. When you ask nosetests to run with the processes plugin, the tests are run in specified number of subprocesses. The xunit plugin does not know how to gather results into the xml file.

Just remove the --processes option and you should be fine.

like image 98
sti Avatar answered Oct 15 '22 07:10

sti


Nose has had an open and unresolved GitHub issue for this since 2011. As @sti said, everything works fine if you don't use --processes. For everyone else, consider using Ignas/nose_xunitmp instead:

pip install nose_xunitmp
nosetests --with-xunitmp
nosetests --xunitmp-file results.xml
like image 26
Cory Klein Avatar answered Oct 15 '22 06:10

Cory Klein