Skip to content

Commit b7381a4

Browse files
[SUREFIRE-1737] Fix disable in statelessTestsetReporter
- old property `disableXmlReport` should be null by default - add ITs - small cleanups
1 parent 5aeca19 commit b7381a4

File tree

6 files changed

+129
-15
lines changed

6 files changed

+129
-15
lines changed

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

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ public abstract class AbstractSurefireMojo extends AbstractMojo implements Suref
709709
* @since 2.2
710710
*/
711711
@Deprecated // todo make readonly to handle system property
712-
@Parameter(property = "disableXmlReport", defaultValue = "false")
712+
@Parameter(property = "disableXmlReport")
713713
private Boolean disableXmlReport;
714714

715715
/**
@@ -2062,8 +2062,8 @@ private StartupReportConfiguration getStartupReportConfiguration(
20622062
SurefireStatelessReporter xmlReporter =
20632063
statelessTestsetReporter == null ? new SurefireStatelessReporter() : statelessTestsetReporter;
20642064

2065-
if (isDisableXmlReport() != null) {
2066-
xmlReporter.setDisable(isDisableXmlReport());
2065+
if (disableXmlReport != null) {
2066+
xmlReporter.setDisable(disableXmlReport);
20672067
}
20682068

20692069
SurefireConsoleOutputReporter outReporter =
@@ -2624,7 +2624,7 @@ private String getConfigChecksum() {
26242624
checksum.add(getParallel());
26252625
checksum.add(isParallelOptimized());
26262626
checksum.add(isTrimStackTrace());
2627-
checksum.add(isDisableXmlReport());
2627+
checksum.add(disableXmlReport);
26282628
checksum.add(isUseSystemClassLoader());
26292629
checksum.add(isUseManifestOnlyJar());
26302630
checksum.add(getEncoding());
@@ -3607,15 +3607,6 @@ public void setTrimStackTrace(boolean trimStackTrace) {
36073607
this.trimStackTrace = trimStackTrace;
36083608
}
36093609

3610-
public Boolean isDisableXmlReport() {
3611-
return disableXmlReport;
3612-
}
3613-
3614-
@SuppressWarnings("UnusedDeclaration")
3615-
public void setDisableXmlReport(Boolean disableXmlReport) {
3616-
this.disableXmlReport = disableXmlReport;
3617-
}
3618-
36193610
public boolean isEnableAssertions() {
36203611
return enableAssertions;
36213612
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public abstract class StatelessReporter<R extends TestSetReportEntry, S, C exten
3636
/**
3737
* {@code false} by default
3838
*/
39-
// todo remove isDisableXmlReport() in AbstractSurefireMojo and use this param instead
4039
private boolean disable;
4140

4241
/**

surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,12 @@ public SurefireLauncher setTestToRun(String basicTest) {
353353
}
354354

355355
public SurefireLauncher setForkJvm() {
356-
mavenLauncher.setForkJvm(true);
356+
setForkJvm(true);
357+
return this;
358+
}
359+
360+
public SurefireLauncher setForkJvm(boolean forkJvm) {
361+
mavenLauncher.setForkJvm(forkJvm);
357362
return this;
358363
}
359364

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.maven.surefire.its.jiras;
20+
21+
import java.io.File;
22+
23+
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
24+
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
25+
import org.junit.Test;
26+
27+
import static org.junit.Assert.assertFalse;
28+
import static org.junit.Assert.assertTrue;
29+
30+
/**
31+
* Integration Tests for SUREFIRE-1737
32+
*/
33+
public class Surefire1737IT extends SurefireJUnit4IntegrationTestCase {
34+
@Test
35+
public void selectJUnit5UsingConfiguredProviderWithPlatformRunner() {
36+
SurefireLauncher launcher = unpack("surefire-1737");
37+
launcher.setForkJvm(false)
38+
.forkNever()
39+
.executeTest()
40+
.verifyTextInLog("Running pkg.JUnit5Test")
41+
.verifyTextInLog(
42+
"Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider");
43+
44+
File baseDir = launcher.getUnpackedAt();
45+
assertTrue(new File(baseDir, "target/surefire-reports/pkg.JUnit5Test.txt").exists());
46+
// xml report should be not generated
47+
File xmlReport = new File(baseDir, "target/surefire-reports/TEST-pkg.JUnit5Test.xml");
48+
assertFalse("xml report: " + xmlReport + " should not be generated", xmlReport.exists());
49+
}
50+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one
4+
~ or more contributor license agreements. See the NOTICE file
5+
~ distributed with this work for additional information
6+
~ regarding copyright ownership. The ASF licenses this file
7+
~ to you under the Apache License, Version 2.0 (the
8+
~ "License"); you may not use this file except in compliance
9+
~ with the License. You may obtain a copy of the License at
10+
~
11+
~ http://www.apache.org/licenses/LICENSE-2.0
12+
~
13+
~ Unless required by applicable law or agreed to in writing,
14+
~ software distributed under the License is distributed on an
15+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
~ KIND, either express or implied. See the License for the
17+
~ specific language governing permissions and limitations
18+
~ under the License.
19+
-->
20+
21+
<project xmlns="http://maven.apache.org/POM/4.0.0"
22+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
26+
<groupId>org.example</groupId>
27+
<artifactId>surefire-1737</artifactId>
28+
<version>1.0-SNAPSHOT</version>
29+
30+
<properties>
31+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
32+
<maven.compiler.source>${java.specification.version}</maven.compiler.source>
33+
<maven.compiler.target>${java.specification.version}</maven.compiler.target>
34+
</properties>
35+
36+
<dependencies>
37+
<dependency>
38+
<groupId>org.junit.jupiter</groupId>
39+
<artifactId>junit-jupiter-api</artifactId>
40+
<version>5.12.1</version>
41+
<scope>test</scope>
42+
</dependency>
43+
</dependencies>
44+
45+
<build>
46+
<plugins>
47+
<plugin>
48+
<groupId>org.apache.maven.plugins</groupId>
49+
<artifactId>maven-surefire-plugin</artifactId>
50+
<version>${surefire.version}</version>
51+
<configuration>
52+
<statelessTestsetReporter>
53+
<disable>true</disable>
54+
</statelessTestsetReporter>
55+
</configuration>
56+
</plugin>
57+
</plugins>
58+
</build>
59+
60+
</project>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package pkg;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
class JUnit5Test {
6+
@Test
7+
public void test() {
8+
}
9+
}

0 commit comments

Comments
 (0)