How to output coverage XML with nosetests?
Asked Answered
C

2

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?

Corr answered 21/1, 2011 at 3:34 Comment(0)
Y
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.

Yonit answered 21/1, 2011 at 3:41 Comment(2)
With which package do you do that? I have installed coverage with pip and it complains about xml module not existingFurcula
@Furcula when python-coverage is installed you can execute it as python -m coverage xml --include="mypackage*"Diapason
A
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

Aberdare answered 25/1, 2011 at 21:42 Comment(2)
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.Corr
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.Aberdare

© 2022 - 2024 — McMap. All rights reserved.