14

I'm trying to output the coverage XML of my nosetests so they show up on Hudson. The line I'm executing is:

nosetests --with-gae -v --all-modules --with-xunit --with-coverage

I see the coverage output in the console, but there's no xml file containing the coverage data. How can I get it to output the coverage xml?

Cuga
  • 17,668
  • 31
  • 111
  • 166

2 Answers2

25

Once you've run the nosetests command, there will be a .coverage data file in the directory. If you then run coverage xml, it will create a Cobertura-compatible XML file from the .coverage file.

Ned Batchelder
  • 364,293
  • 75
  • 561
  • 662
  • With which package do you do that? I have installed coverage with pip and it complains about xml module not existing – hithwen Feb 25 '14 at 15:42
  • @hithwen when python-coverage is installed you can execute it as `python -m coverage xml --include="mypackage*"` – ezdazuzena Aug 07 '14 at 14:18
8

There is a plugin written for nosetests to do just this.

You just have to add --with-xcoverage once this package is installed. It can be found at:

https://github.com/cmheisel/nose-xcover

0 _
  • 10,524
  • 11
  • 77
  • 109
  • Thanks. Does this work better than the other answer? The other way tends to run coverage metrics through all the code on my PYTHONPATH, even if I tell it to just do everything in my 'tests' folder. – Cuga Jan 26 '11 at 03:21
  • 1
    The option I gave is really the same but is done directly through a nose plugin. Add '--cover-package=PACKAGE_NAME' option to limit what code is included in the coverage. – Jeremy Cunningham Feb 02 '11 at 18:06