Skip to content

Commit 3f23643

Browse files
committed
Improve JUnit XSD to be more surefire report compliant.
1 parent 88efbe0 commit 3f23643

File tree

4 files changed

+91
-74
lines changed

4 files changed

+91
-74
lines changed

src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd/junit-10.xsd

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,12 @@ THE SOFTWARE.
103103
</xs:choice>
104104
</xs:sequence>
105105
<xs:attribute name="name" type="xs:string" use="required"/>
106-
<xs:attribute name="assertions" type="xs:string" use="optional"/>
107106
<xs:attribute name="time" type="xs:string" use="optional"/>
108107
<xs:attribute name="timestamp" type="xs:string" use="optional"/>
109108
<xs:attribute name="classname" type="xs:string" use="optional"/>
110109
<xs:attribute name="status" type="xs:string" use="optional"/>
111110
<xs:attribute name="class" type="xs:string" use="optional"/>
112111
<xs:attribute name="file" type="xs:string" use="optional"/>
113-
<xs:attribute name="line" type="xs:string" use="optional"/>
114112
<xs:attribute name="log" type="xs:string" use="optional"/>
115113
<xs:attribute name="group" type="xs:string" use="optional"/>
116114
<xs:attribute name="url" type="xs:string" use="optional"/>
@@ -138,7 +136,6 @@ THE SOFTWARE.
138136
<xs:attribute name="hostname" type="xs:string" use="optional"/>
139137
<xs:attribute name="id" type="xs:string" use="optional"/>
140138
<xs:attribute name="package" type="xs:string" use="optional"/>
141-
<xs:attribute name="assertions" type="xs:string" use="optional"/>
142139
<xs:attribute name="file" type="xs:string" use="optional"/>
143140
<xs:attribute name="skip" type="xs:string" use="optional"/>
144141
<xs:attribute name="log" type="xs:string" use="optional"/>
Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,60 @@
1+
/*
2+
* The MIT License
3+
*
4+
* Copyright (c) 2014, Gregory Boissinot
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
124
package org.jenkinsci.plugins.xunit.types;
225

26+
import java.util.Arrays;
27+
import java.util.Collection;
28+
329
import org.junit.Test;
30+
import org.junit.runner.RunWith;
31+
import org.junit.runners.Parameterized;
32+
import org.junit.runners.Parameterized.Parameters;
433

534
/**
635
* @author Gregory Boissinot
736
*/
37+
@RunWith(Parameterized.class)
838
public class JUnitTypeTest extends AbstractTest {
939

10-
@Test
11-
public void testTestCase1() throws Exception {
12-
convertAndValidate(JUnitInputMetric.class, "junit/testcase1/input.xml", "junit/testcase1/input.xml");
40+
@Parameters(name = "{0}")
41+
public static Collection<Object[]> data() {
42+
return Arrays.asList(new Object[][] { { "test case 1", 1 }, //
43+
{ "test case 2", 2 }, //
44+
{ "test case 3", 3 }, //
45+
{ "test case 4", 4 }, //
46+
{ "test case 5", 5 }
47+
});
1348
}
1449

15-
@Test
16-
public void testTestCase2() throws Exception {
17-
convertAndValidate(JUnitInputMetric.class, "junit/testcase2/input.xml", "junit/testcase2/input.xml");
50+
public JUnitTypeTest(String testName, int testNumber) {
51+
super(JUnitInputMetric.class, resolveInput("junit", testNumber), resolveInput("junit", testNumber));
1852
}
1953

54+
@Override
2055
@Test
21-
public void testTestCase3() throws Exception {
22-
convertAndValidate(JUnitInputMetric.class, "junit/testcase3/input.xml", "junit/testcase3/input.xml");
56+
public void verifyXSLT() throws Exception {
57+
super.verifyXSLT();
2358
}
2459

25-
@Test
26-
public void testTestCase4() throws Exception {
27-
convertAndValidate(JUnitInputMetric.class, "junit/testcase4/input.xml", "junit/testcase4/input.xml");
28-
}
29-
30-
@Test
31-
public void testTestCase5() throws Exception {
32-
convertAndValidate(JUnitInputMetric.class, "junit/testcase5/input.xml", "junit/testcase5/input.xml");
33-
}
34-
}
60+
}

src/test/resources/org/jenkinsci/plugins/xunit/types/junit/testcase2/input.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<testsuite errors="0" tests="2" skipped="0" assertions="5" time="0.243061" failures="0" name="SampleTest">
3-
<testcase assertions="2" time="0.0253" name="test_two">
2+
<testsuite errors="0" tests="2" skipped="0" time="0.243" failures="0" name="SampleTest">
3+
<testcase time="0.025" name="test_two">
44
</testcase>
5-
<testcase assertions="3" time="0.017303" name="test_one">
5+
<testcase time="0.0173" name="test_one">
66
</testcase>
77
<system-out>
88
</system-out>
Lines changed: 44 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,50 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<testsuite name="FiltersTest"
33
file="/var/lib/jenkins/jobs/zend-grid-module/workspace/test-application/tests/FiltersTest.php" tests="32"
4-
assertions="0" failures="0" errors="1" time="452.706041">
5-
<testsuite name="FiltersTest: chrome" tests="16" assertions="0" failures="0" errors="0" time="208.783030">
4+
failures="0" errors="1" time="452.706">
5+
<testsuite name="FiltersTest: chrome" tests="16" failures="0" errors="0" time="208.783">
66
<testcase name="testOnFilterByDateBehavesLikeOr" class="FiltersTest"
77
file="/var/lib/jenkins/jobs/zend-grid-module/workspace/test-application/tests/FiltersTest.php"
8-
line="10" assertions="0" time="20.951486"/>
8+
time="20.951"/>
99
<testcase name="testFilterByTimestampsDoesntTakeIntoAccountTime" class="FiltersTest"
1010
file="/var/lib/jenkins/jobs/zend-grid-module/workspace/test-application/tests/FiltersTest.php"
11-
line="52" assertions="0" time="16.042006"/>
12-
<testsuite name="FiltersTest::testFilterByNull" tests="5" assertions="0" failures="0" errors="0"
13-
time="61.921692">
14-
<testcase name="testFilterByNull with data set #0" assertions="0" time="11.880885"/>
15-
<testcase name="testFilterByNull with data set #1" assertions="0" time="13.163355"/>
16-
<testcase name="testFilterByNull with data set #2" assertions="0" time="12.258866"/>
17-
<testcase name="testFilterByNull with data set #3" assertions="0" time="12.098506"/>
18-
<testcase name="testFilterByNull with data set #4" assertions="0" time="12.520080"/>
11+
time="16.042"/>
12+
<testsuite name="FiltersTest::testFilterByNull" tests="5" failures="0" errors="0"
13+
time="61.921">
14+
<testcase name="testFilterByNull with data set #0" time="11.880"/>
15+
<testcase name="testFilterByNull with data set #1" time="13.163"/>
16+
<testcase name="testFilterByNull with data set #2" time="12.258"/>
17+
<testcase name="testFilterByNull with data set #3" time="12.098"/>
18+
<testcase name="testFilterByNull with data set #4" time="12.520"/>
1919
</testsuite>
20-
<testsuite name="FiltersTest::testFilterByNotNull" tests="4" assertions="0" failures="0" errors="0"
21-
time="50.564510">
22-
<testcase name="testFilterByNotNull with data set #0" assertions="0" time="12.819211"/>
23-
<testcase name="testFilterByNotNull with data set #1" assertions="0" time="12.440420"/>
24-
<testcase name="testFilterByNotNull with data set #2" assertions="0" time="12.710532"/>
25-
<testcase name="testFilterByNotNull with data set #3" assertions="0" time="12.594347"/>
20+
<testsuite name="FiltersTest::testFilterByNotNull" tests="4" failures="0" errors="0"
21+
time="50.564">
22+
<testcase name="testFilterByNotNull with data set #0" time="12.819"/>
23+
<testcase name="testFilterByNotNull with data set #1" time="12.440"/>
24+
<testcase name="testFilterByNotNull with data set #2" time="12.710"/>
25+
<testcase name="testFilterByNotNull with data set #3" time="12.594"/>
2626
</testsuite>
27-
<testsuite name="FiltersTest::testNotEmptyDisablesOtherItems" tests="4" assertions="0" failures="0" errors="0"
28-
time="47.358445">
29-
<testcase name="testNotEmptyDisablesOtherItems with data set #0" assertions="0" time="11.748273"/>
30-
<testcase name="testNotEmptyDisablesOtherItems with data set #1" assertions="0" time="11.702997"/>
31-
<testcase name="testNotEmptyDisablesOtherItems with data set #2" assertions="0" time="11.997253"/>
32-
<testcase name="testNotEmptyDisablesOtherItems with data set #3" assertions="0" time="11.909922"/>
27+
<testsuite name="FiltersTest::testNotEmptyDisablesOtherItems" tests="4" failures="0" errors="0"
28+
time="47.358">
29+
<testcase name="testNotEmptyDisablesOtherItems with data set #0" time="11.748"/>
30+
<testcase name="testNotEmptyDisablesOtherItems with data set #1" time="11.702"/>
31+
<testcase name="testNotEmptyDisablesOtherItems with data set #2" time="11.997"/>
32+
<testcase name="testNotEmptyDisablesOtherItems with data set #3" time="11.909"/>
3333
</testsuite>
34-
<testcase name="testMutuallyExclusiveBooleans" class="FiltersTest"
35-
file="/var/lib/jenkins/jobs/zend-grid-module/workspace/test-application/tests/FiltersTest.php"
36-
line="172" assertions="0" time="11.944891"/>
34+
<testcase name="testMutuallyExclusiveBooleans" class="FiltersTest" file="/var/lib/jenkins/jobs/zend-grid-module/workspace/test-application/tests/FiltersTest.php" time="11.944"/>
3735
</testsuite>
38-
<testsuite name="FiltersTest: internet explorer" tests="16" assertions="0" failures="0" errors="1"
36+
<testsuite name="FiltersTest: internet explorer" tests="16" failures="0" errors="1"
3937
time="243.923011">
4038
<testcase name="testOnFilterByDateBehavesLikeOr" class="FiltersTest"
4139
file="/var/lib/jenkins/jobs/zend-grid-module/workspace/test-application/tests/FiltersTest.php"
42-
line="10" assertions="0" time="34.795199"/>
40+
time="34.795"/>
4341
<testcase name="testFilterByTimestampsDoesntTakeIntoAccountTime" class="FiltersTest"
4442
file="/var/lib/jenkins/jobs/zend-grid-module/workspace/test-application/tests/FiltersTest.php"
45-
line="52" assertions="0" time="22.823278"/>
46-
<testsuite name="FiltersTest::testFilterByNull" tests="5" assertions="0" failures="0" errors="1"
43+
time="22.823"/>
44+
<testsuite name="FiltersTest::testFilterByNull" tests="5" failures="0" errors="1"
4745
time="79.679187">
48-
<testcase name="testFilterByNull with data set #0" assertions="0" time="12.300125"/>
49-
<testcase name="testFilterByNull with data set #1" assertions="0" time="33.122008">
46+
<testcase name="testFilterByNull with data set #0" time="12.300"/>
47+
<testcase name="testFilterByNull with data set #1" time="33.122">
5048
<error type="PHPUnit_Extensions_Selenium2TestCase_WebDriverException">
5149
FiltersTest::testFilterByNull with data set #1 ('publish_date', 1)
5250
PHPUnit_Extensions_Selenium2TestCase_WebDriverException: Unable to find element with xpath ==
@@ -73,26 +71,22 @@
7371
/usr/share/php/PHPUnit/Extensions/Selenium2TestCase.php:258 /usr/bin/phpunit:46
7472
</error>
7573
</testcase>
76-
<testcase name="testFilterByNull with data set #2" assertions="0" time="11.452066"/>
77-
<testcase name="testFilterByNull with data set #3" assertions="0" time="10.645194"/>
78-
<testcase name="testFilterByNull with data set #4" assertions="0" time="12.159794"/>
74+
<testcase name="testFilterByNull with data set #2" time="11.452"/>
75+
<testcase name="testFilterByNull with data set #3" time="10.645"/>
76+
<testcase name="testFilterByNull with data set #4" time="12.159"/>
7977
</testsuite>
80-
<testsuite name="FiltersTest::testFilterByNotNull" tests="4" assertions="0" failures="0" errors="0"
81-
time="47.550400">
82-
<testcase name="testFilterByNotNull with data set #0" assertions="0" time="12.138109"/>
83-
<testcase name="testFilterByNotNull with data set #1" assertions="0" time="11.949402"/>
84-
<testcase name="testFilterByNotNull with data set #2" assertions="0" time="12.296412"/>
85-
<testcase name="testFilterByNotNull with data set #3" assertions="0" time="11.166477"/>
78+
<testsuite name="FiltersTest::testFilterByNotNull" tests="4" failures="0" errors="0" time="47.550">
79+
<testcase name="testFilterByNotNull with data set #0" time="12.138"/>
80+
<testcase name="testFilterByNotNull with data set #1" time="11.949"/>
81+
<testcase name="testFilterByNotNull with data set #2" time="12.296"/>
82+
<testcase name="testFilterByNotNull with data set #3" time="11.166"/>
8683
</testsuite>
87-
<testsuite name="FiltersTest::testNotEmptyDisablesOtherItems" tests="4" assertions="0" failures="0" errors="0"
88-
time="44.270910">
89-
<testcase name="testNotEmptyDisablesOtherItems with data set #0" assertions="0" time="10.235131"/>
90-
<testcase name="testNotEmptyDisablesOtherItems with data set #1" assertions="0" time="10.975805"/>
91-
<testcase name="testNotEmptyDisablesOtherItems with data set #2" assertions="0" time="11.049638"/>
92-
<testcase name="testNotEmptyDisablesOtherItems with data set #3" assertions="0" time="12.010336"/>
84+
<testsuite name="FiltersTest::testNotEmptyDisablesOtherItems" tests="4" failures="0" errors="0" time="44.270">
85+
<testcase name="testNotEmptyDisablesOtherItems with data set #0" time="10.235"/>
86+
<testcase name="testNotEmptyDisablesOtherItems with data set #1" time="10.975"/>
87+
<testcase name="testNotEmptyDisablesOtherItems with data set #2" time="11.049"/>
88+
<testcase name="testNotEmptyDisablesOtherItems with data set #3" time="12.010"/>
9389
</testsuite>
94-
<testcase name="testMutuallyExclusiveBooleans" class="FiltersTest"
95-
file="/var/lib/jenkins/jobs/zend-grid-module/workspace/test-application/tests/FiltersTest.php"
96-
line="172" assertions="0" time="14.804037"/>
90+
<testcase name="testMutuallyExclusiveBooleans" class="FiltersTest" file="/var/lib/jenkins/jobs/zend-grid-module/workspace/test-application/tests/FiltersTest.php" time="14.804"/>
9791
</testsuite>
9892
</testsuite>

0 commit comments

Comments
 (0)