This is an automated email from the ASF dual-hosted git repository.
olamy 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 1601a77c6 fix: warn when matching test classes have no provider (#3567)
1601a77c6 is described below
commit 1601a77c6251f4152d14a8a8e1abf65c47839dc3
Author: OKAN TIKTAS <[email protected]>
AuthorDate: Sat Nov 14 04:03:11 2026 -0500
fix: warn when matching test classes have no provider (#3567)
* fix: warn when test classes have no provider
* test: verify no provider warning for empty test scans
---
.../plugin/surefire/AbstractSurefireMojo.java | 5 +++
.../maven/surefire/its/PojoWithoutProviderIT.java | 41 ++++++++++++++++++++++
.../test/resources/pojo-without-provider/pom.xml | 33 +++++++++++++++++
.../src/test/java/demo/CalculatorTest.java | 25 +++++++++++++
4 files changed, 104 insertions(+)
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 12ff76bf4..8693bc2a9 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
@@ -1373,6 +1373,11 @@ private void executeAfterPreconditionsChecked(@Nonnull
DefaultScanResult scanRes
TestClassPath testClasspath = generateTestClasspath();
List<ProviderInfo> providers = createProviders(testClasspath);
+ if (providers.isEmpty()) {
+ getConsoleLogger()
+ .warning("Test classes were found, but no test provider is
available. "
+ + "POJO tests are no longer supported; add JUnit
or TestNG as a test dependency.");
+ }
ResolvePathResultWrapper wrapper =
findModuleDescriptor(platform.getJdkExecAttributesForTests().getJdkHome());
diff --git
a/surefire-its/src/test/java/org/apache/maven/surefire/its/PojoWithoutProviderIT.java
b/surefire-its/src/test/java/org/apache/maven/surefire/its/PojoWithoutProviderIT.java
new file mode 100644
index 000000000..1b1475576
--- /dev/null
+++
b/surefire-its/src/test/java/org/apache/maven/surefire/its/PojoWithoutProviderIT.java
@@ -0,0 +1,41 @@
+/*
+ * 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;
+
+import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
+import org.apache.maven.surefire.its.fixture.VerificationException;
+import org.junit.jupiter.api.Test;
+
+public class PojoWithoutProviderIT extends SurefireJUnit4IntegrationTestCase {
+ @Test
+ public void warnWhenTestClassesHaveNoProvider() {
+ unpack("pojo-without-provider")
+ .executeTest()
+ .verifyTextInLog("Test classes were found, but no test
provider is available.");
+ }
+
+ @Test
+ public void noWarningWhenNoTestClassesAreFound() throws
VerificationException {
+ unpack("pojo-without-provider")
+ .setTestToRun("DoesNotExist")
+ .failIfNoSpecifiedTests(false)
+ .executeTest()
+ .verifyTextNotInLog("Test classes were found, but no test
provider is available.");
+ }
+}
diff --git a/surefire-its/src/test/resources/pojo-without-provider/pom.xml
b/surefire-its/src/test/resources/pojo-without-provider/pom.xml
new file mode 100644
index 000000000..3a88064e9
--- /dev/null
+++ b/surefire-its/src/test/resources/pojo-without-provider/pom.xml
@@ -0,0 +1,33 @@
+<?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
https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>it-parent</artifactId>
+ <version>1.0</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <groupId>org.apache.maven.plugins.surefire</groupId>
+ <artifactId>pojo-without-provider</artifactId>
+ <version>1.0-SNAPSHOT</version>
+</project>
diff --git
a/surefire-its/src/test/resources/pojo-without-provider/src/test/java/demo/CalculatorTest.java
b/surefire-its/src/test/resources/pojo-without-provider/src/test/java/demo/CalculatorTest.java
new file mode 100644
index 000000000..f545bd890
--- /dev/null
+++
b/surefire-its/src/test/resources/pojo-without-provider/src/test/java/demo/CalculatorTest.java
@@ -0,0 +1,25 @@
+/*
+ * 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 demo;
+
+public class CalculatorTest {
+ public void testAdd() {
+ throw new AssertionError("A POJO test must not silently pass");
+ }
+}