Alex
Alex

Reputation: 44275

How to generate junit output with nosetests?

I have some tests I would like to run with nosetests and generate junit xml results. As far as I know, this is not possible by the default installation of nosetests, as it only produced xunit xml files.

However, nose plugins exist which can do various things, among them a code snippet to be use to create junit xml output.

My questions:

Upvotes: 1

Views: 3719

Answers (3)

Melebius
Melebius

Reputation: 6695

You can get xUnit XML results using nosetests --with-xunit.

JUnit XML is basically the same thing as xUnit XML. The letter before Unit stands for the programming language being tested. From https://en.wikipedia.org/wiki/XUnit:

xUnit is the collective name for several unit testing frameworks that derive their structure and functionality from Smalltalk's SUnit. (…) The names of many of these frameworks are a variation on "SUnit," usually replacing the "S" with the first letter (or letters) in the name of their intended language ("JUnit" for Java, "RUnit" for R, etc.). These frameworks and their common architecture are collectively known as "xUnit".

You cannot get true JUnit XML reports since you are not testing Java but Python with nosetests. However, JUnit and xUnit XML results should be mostly compatible. The Nosetests Xunit documentation claims:

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.

…and later (emphasis mine):

In a Jenkins builder, tick the box named “Publish JUnit test result report”…

Upvotes: 0

Jordan Warbelow-Feldstein
Jordan Warbelow-Feldstein

Reputation: 10748

Nose supports xunit natively, now.

nose supports xunit output with built-in plugin, just try --with-xunit

~ From Oleksiy, https://stackoverflow.com/a/20750012/311901

Upvotes: 3

Greg
Greg

Reputation: 5588

This is a nose plugin; You can install it by

pip install NoseXUnit

Read the documentation for it here: http://nosexunit.sourceforge.net/. This will help you run the plugin

Upvotes: 1

Related Questions