nose-devs / nose

nose is nicer testing for python
http://readthedocs.org/docs/nose/en/latest/
1.36k stars 395 forks source link

Coverage plug xml is not Junit formatted #706

Open IamFive opened 11 years ago

IamFive commented 11 years ago

As title. xml produced by nose coverage is like:

<coverage branch-rate="0" line-rate="0.6575" timestamp="1372305285831" version="3.6">
<!--
 Generated by coverage.py: http://nedbatchelder.com/code/coverage 
-->
<packages>
<package branch-rate="0" complexity="0" line-rate="0.8" name="">
<classes>
<class branch-rate="0" complexity="0" filename="hive/__init__.py" line-rate="0.8" name="hive">
<methods/>
<lines>
<line hits="1" number="11"/>
<line hits="1" number="13"/>
<line hits="1" number="14"/>
<line hits="1" number="16"/>
<line hits="0" number="17"/>
</lines>
</class>
</classes>
</package>

but the format junit parser supports is:

<coverage clover="0.3.3" generated="1367218934">
<project timestamp="1367218934" name="NoseXUnit">
<metrics files="47" loc="4306" coveredconditionals="0" elements="2195" statements="2195" methods="0" coveredmethods="0" coveredstatements="1532" complexity="3" classes="0" ncloc="2195" packages="47" coveredelements="1532" conditionals="0"/>
<package name="hive">
<metrics files="1" loc="0" coveredconditionals="0" elements="0" statements="0" methods="0" coveredmethods="0" coveredstatements="0" complexity="0" classes="0" ncloc="0" coveredelements="0" conditionals="0"/>
</package>
jszakmeister commented 11 years ago

Which junit parser? IIRC, the coverage format actually comes from Cobertura. See this example.

JUnit is for unit testing, and I don't believe it specifies anything related to coverage. Judging by the above, that output is Atlassian Clover's coverage format.

IamFive commented 11 years ago

thanks for the reply, this is my situation: I used NoseXUnit at past and parse cobertura.xml & clover.xml (both generated by NoseXUnit plugin) with Bamboo(From Atlassian). and it works good. But NoseXUnit depend on coverage==2.8.5, so we move to nose with plugin xunit and coverage.

but nose+coverage only give me the cobertura.xml (the coverage xml file) and what i need is clover.xml. here is my options:

[nosetests]
with-coverage = 1
cover-html = 1
cover-html-dir = ../hive_test/cover
cover-xml = 1
cover-xml-file = ../hive_test/cover.xml
cover-erase = 1
cover-package = hive
with-xunit = 1
xunit-file = ./hive_test/nosexunit.xml
where = hive_test

BTW: the file produced by NoseXUnit plugin is here: clover.xml https://gist.github.com/IamFive/5875822 cobertura.xml https://gist.github.com/IamFive/5875815