You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2022/03/30 08:39:31 UTC

[maven-surefire] branch SUREFIRE-2024 updated: clarified after discussion, added default profile

This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch SUREFIRE-2024
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git


The following commit(s) were added to refs/heads/SUREFIRE-2024 by this push:
     new 4444fa3  clarified after discussion, added default profile
4444fa3 is described below

commit 4444fa3124721875f9422eac1d396649de3ecb1e
Author: tibordigana <ti...@apache.org>
AuthorDate: Wed Mar 30 10:39:20 2022 +0200

    clarified after discussion, added default profile
---
 .../src/site/apt/examples/junit-platform.apt.vm    |  8 +----
 .../surefire/its/jiras/Surefire1787JUnit5IT.java   | 13 +++++++-
 .../src/test/resources/junit5-testng/pom.xml       | 37 +++++++++++++++++++++-
 .../src/test/java/pkg/JUnit5Test.java              |  2 +-
 4 files changed, 50 insertions(+), 10 deletions(-)

diff --git a/maven-surefire-plugin/src/site/apt/examples/junit-platform.apt.vm b/maven-surefire-plugin/src/site/apt/examples/junit-platform.apt.vm
index b413e58..26e5f1b 100644
--- a/maven-surefire-plugin/src/site/apt/examples/junit-platform.apt.vm
+++ b/maven-surefire-plugin/src/site/apt/examples/junit-platform.apt.vm
@@ -371,17 +371,11 @@ Using JUnit 5 Platform
         <version>1.0.1</version>
         <scope>test</scope>
     </dependency>
-    <dependency>
-        <groupId>org.junit.jupiter</groupId>
-        <artifactId>junit-jupiter-api</artifactId>
-        <version>5.8.2</version>
-        <scope>test</scope>
-    </dependency>
 </dependencies>
 +---+
 
   The Maven does not take any responsibility for broken compatibilities in this case and the responsibility for
-  the dependency <<<com.github.testng-team:testng-junit5>>>.
+  the dependency <<<org.junit.support:testng-engine>>>.
 
 ** JUnit Runner
 
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1787JUnit5IT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1787JUnit5IT.java
index f64ad70..ede3d11 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1787JUnit5IT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1787JUnit5IT.java
@@ -97,6 +97,18 @@ public class Surefire1787JUnit5IT extends SurefireJUnit4IntegrationTestCase
     }
 
     @Test
+    public void testNg()
+    {
+        unpack( "junit5-testng" )
+            .activateProfile( "testng-only" )
+            .executeTest()
+            .verifyErrorFree( 1 )
+            .verifyTextInLog( "Running pkg.TestNGTest" )
+            .verifyTextInLog(
+                "Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider" );
+    }
+
+    @Test
     public void testNgWithJupiterApi()
     {
         unpack( "junit5-testng" )
@@ -107,7 +119,6 @@ public class Surefire1787JUnit5IT extends SurefireJUnit4IntegrationTestCase
             .verifyTextInLog( "Running pkg.TestNGTest" )
             .verifyTextInLog(
                 "Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider" );
-
     }
 
     @Test
diff --git a/surefire-its/src/test/resources/junit5-testng/pom.xml b/surefire-its/src/test/resources/junit5-testng/pom.xml
index 2f8cf9d..fd38310 100644
--- a/surefire-its/src/test/resources/junit5-testng/pom.xml
+++ b/surefire-its/src/test/resources/junit5-testng/pom.xml
@@ -39,7 +39,7 @@
     <dependency>
       <groupId>org.testng</groupId>
       <artifactId>testng</artifactId>
-      <version>7.4.0</version>
+      <version>7.5</version>
       <scope>test</scope>
     </dependency>
     <dependency>
@@ -64,6 +64,23 @@
 
   <profiles>
     <profile>
+      <id>testng-only</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-compiler-plugin</artifactId>
+            <configuration>
+              <testIncludes>
+                <!-- JUnit5Test.java ignored - Jupiter does not exist in dependencies. -->
+                <testInclude>**/TestNGTest.java</testInclude>
+              </testIncludes>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+    <profile>
       <id>junit5-engine</id>
       <dependencies>
         <dependency>
@@ -78,6 +95,24 @@
     </profile>
     <profile>
       <id>junit5-api</id>
+      <!--
+      This exclusion avoids inconsistent versions combination: junit-platform-engine:1.7.2 and junit-jupiter-api:5.8.2.
+      The surefire would add artifacts to the class path: junit-platform-*, junit-jupiter-engine, etc.
+      -->
+      <dependencyManagement>
+        <dependencies>
+          <dependency>
+            <groupId>org.junit.support</groupId>
+            <artifactId>testng-engine</artifactId>
+            <exclusions>
+              <exclusion>
+                <groupId>org.junit.platform</groupId>
+                <artifactId>junit-platform-engine</artifactId>
+              </exclusion>
+            </exclusions>
+          </dependency>
+        </dependencies>
+      </dependencyManagement>
       <dependencies>
         <dependency>
           <groupId>org.junit.jupiter</groupId>
diff --git a/surefire-its/src/test/resources/junit5-testng/src/test/java/pkg/JUnit5Test.java b/surefire-its/src/test/resources/junit5-testng/src/test/java/pkg/JUnit5Test.java
index 916eeab..eea7289 100644
--- a/surefire-its/src/test/resources/junit5-testng/src/test/java/pkg/JUnit5Test.java
+++ b/surefire-its/src/test/resources/junit5-testng/src/test/java/pkg/JUnit5Test.java
@@ -4,7 +4,7 @@ import org.junit.jupiter.api.Test;
 
 class JUnit5Test {
     @Test
-    public void test() {
+    void test() {
 
     }
 }