This is an automated email from the ASF dual-hosted git repository.
sjaranowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
The following commit(s) were added to refs/heads/master by this push:
new b7381a42a [SUREFIRE-1737] Fix disable in statelessTestsetReporter
b7381a42a is described below
commit b7381a42ab5bffc15b0089a0cc498ae79aeba4fe
Author: Slawomir Jaranowski <[email protected]>
AuthorDate: Sun Mar 23 12:19:47 2025 +0100
[SUREFIRE-1737] Fix disable in statelessTestsetReporter
- old property `disableXmlReport` should be null by default
- add ITs
- small cleanups
---
.../plugin/surefire/AbstractSurefireMojo.java | 17 ++----
.../surefire/extensions/StatelessReporter.java | 1 -
.../surefire/its/fixture/SurefireLauncher.java | 7 ++-
.../maven/surefire/its/jiras/Surefire1737IT.java | 50 ++++++++++++++++++
.../src/test/resources/surefire-1737/pom.xml | 60 ++++++++++++++++++++++
.../src/test/java/pkg/JUnit5Test.java | 9 ++++
6 files changed, 129 insertions(+), 15 deletions(-)
diff --git
a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
index 42a769c46..b783d73be 100644
---
a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
+++
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
@@ -709,7 +709,7 @@ public abstract class AbstractSurefireMojo extends
AbstractMojo implements Suref
* @since 2.2
*/
@Deprecated // todo make readonly to handle system property
- @Parameter(property = "disableXmlReport", defaultValue = "false")
+ @Parameter(property = "disableXmlReport")
private Boolean disableXmlReport;
/**
@@ -2062,8 +2062,8 @@ private StartupReportConfiguration
getStartupReportConfiguration(
SurefireStatelessReporter xmlReporter =
statelessTestsetReporter == null ? new
SurefireStatelessReporter() : statelessTestsetReporter;
- if (isDisableXmlReport() != null) {
- xmlReporter.setDisable(isDisableXmlReport());
+ if (disableXmlReport != null) {
+ xmlReporter.setDisable(disableXmlReport);
}
SurefireConsoleOutputReporter outReporter =
@@ -2624,7 +2624,7 @@ private String getConfigChecksum() {
checksum.add(getParallel());
checksum.add(isParallelOptimized());
checksum.add(isTrimStackTrace());
- checksum.add(isDisableXmlReport());
+ checksum.add(disableXmlReport);
checksum.add(isUseSystemClassLoader());
checksum.add(isUseManifestOnlyJar());
checksum.add(getEncoding());
@@ -3607,15 +3607,6 @@ public void setTrimStackTrace(boolean trimStackTrace) {
this.trimStackTrace = trimStackTrace;
}
- public Boolean isDisableXmlReport() {
- return disableXmlReport;
- }
-
- @SuppressWarnings("UnusedDeclaration")
- public void setDisableXmlReport(Boolean disableXmlReport) {
- this.disableXmlReport = disableXmlReport;
- }
-
public boolean isEnableAssertions() {
return enableAssertions;
}
diff --git
a/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/StatelessReporter.java
b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/StatelessReporter.java
index 3cf833daa..da330c02e 100644
---
a/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/StatelessReporter.java
+++
b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/StatelessReporter.java
@@ -36,7 +36,6 @@ public abstract class StatelessReporter<R extends
TestSetReportEntry, S, C exten
/**
* {@code false} by default
*/
- // todo remove isDisableXmlReport() in AbstractSurefireMojo and use this
param instead
private boolean disable;
/**
diff --git
a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
index 0337e92ef..466513892 100755
---
a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
+++
b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
@@ -353,7 +353,12 @@ public SurefireLauncher setTestToRun(String basicTest) {
}
public SurefireLauncher setForkJvm() {
- mavenLauncher.setForkJvm(true);
+ setForkJvm(true);
+ return this;
+ }
+
+ public SurefireLauncher setForkJvm(boolean forkJvm) {
+ mavenLauncher.setForkJvm(forkJvm);
return this;
}
diff --git
a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1737IT.java
b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1737IT.java
new file mode 100644
index 000000000..041be27c3
--- /dev/null
+++
b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1737IT.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.surefire.its.jiras;
+
+import java.io.File;
+
+import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
+import org.apache.maven.surefire.its.fixture.SurefireLauncher;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Integration Tests for SUREFIRE-1737
+ */
+public class Surefire1737IT extends SurefireJUnit4IntegrationTestCase {
+ @Test
+ public void selectJUnit5UsingConfiguredProviderWithPlatformRunner() {
+ SurefireLauncher launcher = unpack("surefire-1737");
+ launcher.setForkJvm(false)
+ .forkNever()
+ .executeTest()
+ .verifyTextInLog("Running pkg.JUnit5Test")
+ .verifyTextInLog(
+ "Using auto detected provider
org.apache.maven.surefire.junitplatform.JUnitPlatformProvider");
+
+ File baseDir = launcher.getUnpackedAt();
+ assertTrue(new File(baseDir,
"target/surefire-reports/pkg.JUnit5Test.txt").exists());
+ // xml report should be not generated
+ File xmlReport = new File(baseDir,
"target/surefire-reports/TEST-pkg.JUnit5Test.xml");
+ assertFalse("xml report: " + xmlReport + " should not be generated",
xmlReport.exists());
+ }
+}
diff --git a/surefire-its/src/test/resources/surefire-1737/pom.xml
b/surefire-its/src/test/resources/surefire-1737/pom.xml
new file mode 100644
index 000000000..69ae62e11
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1737/pom.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.example</groupId>
+ <artifactId>surefire-1737</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+
<maven.compiler.source>${java.specification.version}</maven.compiler.source>
+
<maven.compiler.target>${java.specification.version}</maven.compiler.target>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>5.12.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.version}</version>
+ <configuration>
+ <statelessTestsetReporter>
+ <disable>true</disable>
+ </statelessTestsetReporter>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git
a/surefire-its/src/test/resources/surefire-1737/src/test/java/pkg/JUnit5Test.java
b/surefire-its/src/test/resources/surefire-1737/src/test/java/pkg/JUnit5Test.java
new file mode 100644
index 000000000..84cce1b6a
--- /dev/null
+++
b/surefire-its/src/test/resources/surefire-1737/src/test/java/pkg/JUnit5Test.java
@@ -0,0 +1,9 @@
+package pkg;
+
+import org.junit.jupiter.api.Test;
+
+class JUnit5Test {
+ @Test
+ public void test() {
+ }
+}