publishers: xunit doesn't accepts integers as threshold

* Accept integers for threshold
 In documentation is written that threshold should be integer.
 But it fails with integer to generate XML.
 Only case when it pass is for 0, because XML formatter consider it as
 empty body and do not format it.

* Fix documentation for missing threshold field, plus test.
 In documentation it says that missing threshold is set to 0, but apparently
 it is set to Null (empty field), and it has different behaviour than for 0
 value.

Change-Id: I326cbadd955c4c28f315fa72293d9a54a116b140
This commit is contained in:
Lukas Bednar 2015-11-12 13:20:40 +01:00
parent 78411048f6
commit 1cf55db557
5 changed files with 59 additions and 17 deletions

View File

@ -1103,7 +1103,7 @@ def xunit(parser, xml_parent, data):
# Normalize and craft the element name for this threshold
elname = "%sThreshold" % threshold_name.lower().replace(
'new', 'New')
XML.SubElement(el, elname).text = threshold_value
XML.SubElement(el, elname).text = str(threshold_value)
# Whether to use percent of exact number of tests.
# Thresholdmode is either:

View File

@ -27,16 +27,16 @@
</types>
<thresholds>
<org.jenkinsci.plugins.xunit.threshold.FailedThreshold>
<unstableThreshold/>
<unstableNewThreshold/>
<failureThreshold/>
<failureNewThreshold/>
<unstableThreshold>0</unstableThreshold>
<unstableNewThreshold>0</unstableNewThreshold>
<failureThreshold>0</failureThreshold>
<failureNewThreshold>0</failureNewThreshold>
</org.jenkinsci.plugins.xunit.threshold.FailedThreshold>
<org.jenkinsci.plugins.xunit.threshold.SkippedThreshold>
<unstableThreshold/>
<unstableNewThreshold/>
<failureThreshold/>
<failureNewThreshold/>
<unstableThreshold>0</unstableThreshold>
<unstableNewThreshold>0</unstableNewThreshold>
<failureThreshold>0</failureThreshold>
<failureNewThreshold>0</failureNewThreshold>
</org.jenkinsci.plugins.xunit.threshold.SkippedThreshold>
</thresholds>
<thresholdMode>2</thresholdMode>

View File

@ -4,15 +4,15 @@ publishers:
thresholdmode: 'number'
thresholds:
- failed:
unstable: '1'
unstablenew: '2'
failure: '3'
failurenew: '4'
unstable: 1
unstablenew: 2
failure: 3
failurenew: 4
- skipped:
unstable: '5'
unstablenew: '6'
failure: '7'
failurenew: '8'
unstable: 5
unstablenew: 6
failure: 7
failurenew: 8
types:
- ctest:
pattern: "build/tests/reports/ctest.xml"

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<publishers>
<xunit>
<types>
<PHPUnitJunitHudsonTestType>
<pattern>junit.log</pattern>
<failIfNotNew>true</failIfNotNew>
<deleteOutputFiles>true</deleteOutputFiles>
<skipNoTestFiles>false</skipNoTestFiles>
<stopProcessingIfError>true</stopProcessingIfError>
</PHPUnitJunitHudsonTestType>
</types>
<thresholds>
<org.jenkinsci.plugins.xunit.threshold.FailedThreshold>
<unstableThreshold>10</unstableThreshold>
<failureThreshold>5</failureThreshold>
</org.jenkinsci.plugins.xunit.threshold.FailedThreshold>
<org.jenkinsci.plugins.xunit.threshold.SkippedThreshold>
<unstableNewThreshold>5</unstableNewThreshold>
<failureNewThreshold>10</failureNewThreshold>
</org.jenkinsci.plugins.xunit.threshold.SkippedThreshold>
</thresholds>
<thresholdMode>1</thresholdMode>
<extraConfiguration>
<testTimeMargin>3000</testTimeMargin>
</extraConfiguration>
</xunit>
</publishers>
</project>

View File

@ -0,0 +1,12 @@
publishers:
- xunit:
thresholds:
- failed:
unstable: 10
failure: 5
- skipped:
unstablenew: 5
failurenew: 10
types:
- phpunit:
pattern: "junit.log"