Skip to content

Commit cad0931

Browse files
committed
[SUREFIRE-2248] Make "type" attribute on failures and errors in (surefire|failsafe)-test-report schema optional
This closes #746
1 parent a88d786 commit cad0931

File tree

12 files changed

+34
-33
lines changed

12 files changed

+34
-33
lines changed

maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1936,7 +1936,7 @@ private Artifact getShadefireArtifact() {
19361936

19371937
private StartupReportConfiguration getStartupReportConfiguration(String configChecksum, boolean isForking) {
19381938
SurefireStatelessReporter xmlReporter = statelessTestsetReporter == null
1939-
? new SurefireStatelessReporter(/*todo call def. constr.*/ isDisableXmlReport(), "3.0")
1939+
? new SurefireStatelessReporter(/*todo call def. constr.*/ isDisableXmlReport(), "3.0.1")
19401940
: statelessTestsetReporter;
19411941

19421942
xmlReporter.setDisable(isDisableXmlReport()); // todo change to Boolean in the version 3.0.0-M6

maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/SurefireStatelessReporter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ public class SurefireStatelessReporter
4141
* Activated in the injection point of MOJO.
4242
*/
4343
public SurefireStatelessReporter() {
44-
this(false, "3.0");
44+
this(false, "3.0.1");
4545
}
4646

4747
/**
4848
* Activated if null injection point in MOJO.
4949
* @param disable {@code true} to disable performing the report
50-
* @param version (xsd 3.0) version of the schema
50+
* @param version version of the schema
5151
*/
5252
public SurefireStatelessReporter(boolean disable, String version) {
5353
setDisable(disable);

maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/junit5/JUnit5Xml30StatelessReporter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.apache.maven.surefire.extensions.StatelessReportEventListener;
2727

2828
/**
29-
* The extension of {@link StatelessReportEventListener xml reporter} based on XSD version 3.0 for JUnit5.
29+
* The extension of {@link StatelessReportEventListener xml reporter} based on XSD version 3.0.1 for JUnit5.
3030
* Selectively enables phrased classes, methods and report files upon JUnit5 annotation <em>DisplayName</em>.
3131
*
3232
* author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>

maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/MojoMocklessTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void testGetStartupReportConfiguration() throws Exception {
6767
@Test
6868
public void testGetStartupReportConfiguration2() throws Exception {
6969
AbstractSurefireMojo surefirePlugin = new Mojo(null, null);
70-
SurefireStatelessReporter xmlReporter = new SurefireStatelessReporter(false, "3.0");
70+
SurefireStatelessReporter xmlReporter = new SurefireStatelessReporter();
7171
SurefireConsoleOutputReporter consoleReporter = new SurefireConsoleOutputReporter();
7272
SurefireStatelessTestsetInfoReporter testsetInfoReporter = new SurefireStatelessTestsetInfoReporter();
7373
setInternalState(surefirePlugin, "statelessTestsetReporter", xmlReporter);

maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/extensions/StatelessReporterTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void shouldCloneXmlReporter() {
5555
@Test
5656
public void shouldAssertToStringXmlReporter() {
5757
SurefireStatelessReporter extension = new SurefireStatelessReporter();
58-
assertThat(extension.toString()).isEqualTo("SurefireStatelessReporter{version=3.0, disable=false}");
58+
assertThat(extension.toString()).isEqualTo("SurefireStatelessReporter{version=3.0.1, disable=false}");
5959
}
6060

6161
@Test
@@ -69,7 +69,7 @@ public void shouldCreateConsoleListener() {
6969
reportsDirectory, reportNameSuffix, true, 5, schema, testClassMethodRunHistory);
7070
SurefireStatelessReporter extension = new SurefireStatelessReporter();
7171

72-
assertThat(extension.getVersion()).isEqualTo("3.0");
72+
assertThat(extension.getVersion()).isEqualTo("3.0.1");
7373
extension.setVersion("V3");
7474
assertThat(extension.getVersion()).isEqualTo("V3");
7575

@@ -128,7 +128,7 @@ public void shouldCloneJUnit5XmlReporter() {
128128
public void shouldAssertToStringJUnit5ConsoleReporter() {
129129
JUnit5Xml30StatelessReporter extension = new JUnit5Xml30StatelessReporter();
130130
assertThat(extension.toString())
131-
.isEqualTo("JUnit5Xml30StatelessReporter{version=3.0, disable=false, "
131+
.isEqualTo("JUnit5Xml30StatelessReporter{version=3.0.1, disable=false, "
132132
+ "usePhrasedFileName=false, usePhrasedTestSuiteClassName=false, "
133133
+ "usePhrasedTestCaseClassName=false, usePhrasedTestCaseMethodName=false}");
134134
}
@@ -144,7 +144,7 @@ public void shouldCreateJUnit5ConsoleListener() {
144144
reportsDirectory, reportNameSuffix, true, 5, schema, testClassMethodRunHistory);
145145
JUnit5Xml30StatelessReporter extension = new JUnit5Xml30StatelessReporter();
146146

147-
assertThat(extension.getVersion()).isEqualTo("3.0");
147+
assertThat(extension.getVersion()).isEqualTo("3.0.1");
148148
extension.setVersion("V3");
149149
assertThat(extension.getVersion()).isEqualTo("V3");
150150

maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporterTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void testFileNameWithoutSuffix() {
105105
0,
106106
new ConcurrentHashMap<String, Deque<WrappedReportEntry>>(),
107107
XSD,
108-
"3.0",
108+
"3.0.1",
109109
false,
110110
false,
111111
false,
@@ -165,7 +165,7 @@ public void testAllFieldsSerialized() throws IOException {
165165
0,
166166
new ConcurrentHashMap<String, Deque<WrappedReportEntry>>(),
167167
XSD,
168-
"3.0",
168+
"3.0.1",
169169
false,
170170
false,
171171
false,
@@ -267,7 +267,7 @@ public void testOutputRerunFlakyFailure() throws IOException {
267267
1,
268268
new HashMap<String, Deque<WrappedReportEntry>>(),
269269
XSD,
270-
"3.0",
270+
"3.0.1",
271271
false,
272272
false,
273273
false,
@@ -370,7 +370,7 @@ public void testOutputRerunFlakyAssumption() throws IOException {
370370
rerunStats.testSucceeded(testTwoSecondError);
371371

372372
StatelessXmlReporter reporter = new StatelessXmlReporter(
373-
reportDir, null, false, 1, new HashMap<>(), XSD, "3.0", false, false, false, false);
373+
reportDir, null, false, 1, new HashMap<>(), XSD, "3.0.1", false, false, false, false);
374374

375375
WrappedReportEntry testSetReportEntry = new WrappedReportEntry(
376376
new SimpleReportEntry(

maven-surefire-plugin/src/site/apt/examples/junit-platform.apt.vm

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
------
66
2018-05-14
77
------
8-
8+
99
~~ Licensed to the Apache Software Foundation (ASF) under one
1010
~~ or more contributor license agreements. See the NOTICE file
1111
~~ distributed with this work for additional information
@@ -24,7 +24,7 @@
2424
~~ under the License.
2525

2626
~~ NOTE: For help with the syntax of this file, see:
27-
~~ http://maven.apache.org/doxia/references/apt-format.html
27+
~~ http://maven.apache.org/doxia/references/apt-format.html
2828

2929
Using JUnit 5 Platform
3030

@@ -632,7 +632,7 @@ else
632632
<configuration>
633633
<statelessTestsetReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5Xml30StatelessReporter">
634634
<disable>false</disable>
635-
<version>3.0</version>
635+
<version>3.0.1</version>
636636
<usePhrasedFileName>false</usePhrasedFileName>
637637
<usePhrasedTestSuiteClassName>true</usePhrasedTestSuiteClassName>
638638
<usePhrasedTestCaseClassName>true</usePhrasedTestCaseClassName>

maven-surefire-plugin/src/site/resources/xsd/surefire-test-report.xsd

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
~ specific language governing permissions and limitations
1818
~ under the License.
1919
-->
20-
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="3.0">
20+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="3.0.1">
2121
<xs:element name="testsuite">
2222
<xs:complexType>
2323
<xs:sequence>
@@ -41,7 +41,7 @@
4141
<xs:simpleContent>
4242
<xs:extension base="xs:string">
4343
<xs:attribute name="message" type="xs:string"/>
44-
<xs:attribute name="type" type="xs:string" use="required"/>
44+
<xs:attribute name="type" type="xs:string"/>
4545
</xs:extension>
4646
</xs:simpleContent>
4747
</xs:complexType>
@@ -54,7 +54,7 @@
5454
<xs:element name="system-err" type="xs:string" minOccurs="0"/>
5555
</xs:sequence>
5656
<xs:attribute name="message" type="xs:string"/>
57-
<xs:attribute name="type" type="xs:string" use="required"/>
57+
<xs:attribute name="type" type="xs:string"/>
5858
</xs:complexType>
5959
</xs:element>
6060
<xs:element name="flakyFailure" minOccurs="0" maxOccurs="unbounded">
@@ -65,7 +65,7 @@
6565
<xs:element name="system-err" type="xs:string" minOccurs="0"/>
6666
</xs:sequence>
6767
<xs:attribute name="message" type="xs:string"/>
68-
<xs:attribute name="type" type="xs:string" use="required"/>
68+
<xs:attribute name="type" type="xs:string"/>
6969
</xs:complexType>
7070
</xs:element>
7171
<xs:element name="skipped" nillable="true" minOccurs="0" maxOccurs="1">
@@ -82,7 +82,7 @@
8282
<xs:simpleContent>
8383
<xs:extension base="xs:string">
8484
<xs:attribute name="message" type="xs:string"/>
85-
<xs:attribute name="type" type="xs:string" use="required"/>
85+
<xs:attribute name="type" type="xs:string"/>
8686
</xs:extension>
8787
</xs:simpleContent>
8888
</xs:complexType>
@@ -95,7 +95,7 @@
9595
<xs:element name="system-err" type="xs:string" minOccurs="0"/>
9696
</xs:sequence>
9797
<xs:attribute name="message" type="xs:string"/>
98-
<xs:attribute name="type" type="xs:string" use="required"/>
98+
<xs:attribute name="type" type="xs:string"/>
9999
</xs:complexType>
100100
</xs:element>
101101
<xs:element name="flakyError" minOccurs="0" maxOccurs="unbounded">
@@ -106,7 +106,7 @@
106106
<xs:element name="system-err" type="xs:string" minOccurs="0"/>
107107
</xs:sequence>
108108
<xs:attribute name="message" type="xs:string"/>
109-
<xs:attribute name="type" type="xs:string" use="required"/>
109+
<xs:attribute name="type" type="xs:string"/>
110110
</xs:complexType>
111111
</xs:element>
112112
<xs:element name="system-out" type="xs:string" minOccurs="0"/>

maven-surefire-report-plugin/src/test/resources/surefire-1894/TEST-surefire.MyTest.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<testsuite name="surefire.MyTest" version="3.0" time="0" tests="1" errors="1" skipped="0" failures="0">
2+
<testsuite name="surefire.MyTest" version="3.0.1" time="0" tests="1" errors="1" skipped="0" failures="0">
33
<properties>
44
<property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
55
</properties>
@@ -41,4 +41,4 @@
4141
... 26 more
4242
</error>
4343
</testcase>
44-
</testsuite>
44+
</testsuite>

surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/StatelessReporter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public abstract class StatelessReporter<R extends TestSetReportEntry, S, C exten
4040
private boolean disable;
4141

4242
/**
43-
* Version of reporter. It is version <em>3.0</em> used by default in XML reporter.
43+
* Version of reporter. It is version <em>3.0.1</em> used by default in XML reporter.
4444
*/
4545
private String version;
4646

@@ -62,7 +62,7 @@ public void setDisable(boolean disable) {
6262
}
6363

6464
public String getVersion() {
65-
return isBlank(version) ? "3.0" : version;
65+
return isBlank(version) ? "3.0.1" : version;
6666
}
6767

6868
public void setVersion(String version) {

surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformEnginesIT.java

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
@RunWith(Parameterized.class)
4949
@SuppressWarnings("checkstyle:magicnumber")
5050
public class JUnitPlatformEnginesIT extends SurefireJUnit4IntegrationTestCase {
51+
// This must correspond to the Surefire version uses for testing
5152
private static final String XML_TESTSUITE_FRAGMENT =
5253
"<testsuite xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation="
5354
+ "\"https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd\" "

surefire-report-parser/src/test/resources/fixture/testsuitexmlparser/TEST-org.acme.FlakyTest.xml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<testsuite version="3.0" name="org.acme.FlakyTest" time="1.324" tests="1" errors="0" skipped="0" failures="0">
2+
<testsuite version="3.0.1" name="org.acme.FlakyTest" time="1.324" tests="1" errors="0" skipped="0" failures="0">
33
<properties>
44
<property name="java.class.version" value="55.0"/>
55
</properties>
@@ -88,7 +88,7 @@
8888
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495)
8989
]]></stackTrace>
9090
<system-out><![CDATA[2023-06-23 17:27:31,351 INFO [io.quarkus] (main) code-with-quarkus 1.0.0-SNAPSHOT on JVM (powered by Quarkus 3.1.2.Final) started in 1.493s. Listening on: http://localhost:8081
91-
2023-06-23 17:27:31,353 INFO [io.quarkus] (main) Profile test activated.
91+
2023-06-23 17:27:31,353 INFO [io.quarkus] (main) Profile test activated.
9292
2023-06-23 17:27:31,353 INFO [io.quarkus] (main) Installed features: [cdi, resteasy-reactive, smallrye-context-propagation, vertx]
9393
]]></system-out>
9494
</flakyFailure>
@@ -176,7 +176,7 @@
176176
]]></stackTrace>
177177
<system-out><![CDATA[2023-06-23 17:27:31,695 INFO [io.quarkus] (main) code-with-quarkus stopped in 0.022s
178178
2023-06-23 17:27:33,059 INFO [io.quarkus] (main) code-with-quarkus 1.0.0-SNAPSHOT on JVM (powered by Quarkus 3.1.2.Final) started in 1.200s. Listening on: http://localhost:8081
179-
2023-06-23 17:27:33,059 INFO [io.quarkus] (main) Profile test activated.
179+
2023-06-23 17:27:33,059 INFO [io.quarkus] (main) Profile test activated.
180180
2023-06-23 17:27:33,059 INFO [io.quarkus] (main) Installed features: [cdi, resteasy-reactive, smallrye-context-propagation, vertx]
181181
]]></system-out>
182182
</flakyFailure>
@@ -264,7 +264,7 @@
264264
]]></stackTrace>
265265
<system-out><![CDATA[2023-06-23 17:27:33,117 INFO [io.quarkus] (main) code-with-quarkus stopped in 0.016s
266266
2023-06-23 17:27:34,404 INFO [io.quarkus] (main) code-with-quarkus 1.0.0-SNAPSHOT on JVM (powered by Quarkus 3.1.2.Final) started in 1.180s. Listening on: http://localhost:8081
267-
2023-06-23 17:27:34,404 INFO [io.quarkus] (main) Profile test activated.
267+
2023-06-23 17:27:34,404 INFO [io.quarkus] (main) Profile test activated.
268268
2023-06-23 17:27:34,404 INFO [io.quarkus] (main) Installed features: [cdi, resteasy-reactive, smallrye-context-propagation, vertx]
269269
]]></system-out>
270270
</flakyFailure>
@@ -352,12 +352,12 @@
352352
]]></stackTrace>
353353
<system-out><![CDATA[2023-06-23 17:27:34,461 INFO [io.quarkus] (main) code-with-quarkus stopped in 0.014s
354354
2023-06-23 17:27:35,705 INFO [io.quarkus] (main) code-with-quarkus 1.0.0-SNAPSHOT on JVM (powered by Quarkus 3.1.2.Final) started in 1.159s. Listening on: http://localhost:8081
355-
2023-06-23 17:27:35,705 INFO [io.quarkus] (main) Profile test activated.
355+
2023-06-23 17:27:35,705 INFO [io.quarkus] (main) Profile test activated.
356356
2023-06-23 17:27:35,705 INFO [io.quarkus] (main) Installed features: [cdi, resteasy-reactive, smallrye-context-propagation, vertx]
357357
]]></system-out>
358358
<system-err><![CDATA[Test system.err
359359
]]></system-err>
360360
</flakyError>
361361
</testcase>
362362
<testcase name="testStable" classname="org.acme.FlakyTest" time="0.001"/>
363-
</testsuite>
363+
</testsuite>

0 commit comments

Comments
 (0)