You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2022/03/26 14:42:55 UTC

[maven-surefire] 01/01: [SUREFIRE-2024] Replace testng-junit5 by testng-engine

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

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

commit 60bde3e3c143b9001e9bec13bc22e16b1fa0aff9
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Sat Mar 26 15:40:41 2022 +0100

    [SUREFIRE-2024] Replace testng-junit5 by testng-engine
---
 .../src/site/apt/examples/junit-platform.apt.vm    |  22 ++--
 .../surefire/its/jiras/Surefire1787JUnit5IT.java   |  12 +-
 .../src/test/resources/junit5-testng-only/pom.xml  |  64 +++++++++++
 .../src/test/java/pkg/TestNGTest.java              |  10 ++
 .../src/test/resources/junit5-testng/pom.xml       | 123 ++++++++++-----------
 5 files changed, 154 insertions(+), 77 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 e1426a6..ea882af 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
@@ -79,7 +79,6 @@ Using JUnit 5 Platform
   JUnit5 API artifact and your test sources become isolated from engine. In these chapters you will see how you can
   segregate, combine, select the APIs and Engines miscellaneous way. You can find integration tests
   {{{https://github.com/apache/maven-surefire/tree/master/surefire-its/src/test/resources/junit-4-5}with JUnit4/5}},
-  {{{https://github.com/apache/maven-surefire/tree/master/surefire-its/src/test/resources/junit5-testng}with JUnit5/TestNG}}
   and {{{https://github.com/apache/maven-surefire/tree/master/surefire-its/src/test/resources/junit5-runner}with the JUnit4 Runner for Jupiter tests}}.
   (See the Maven profiles.)
 
@@ -347,37 +346,32 @@ Using JUnit 5 Platform
 </profile>
 +---+
 
-** How to run TestNG tests within Jupiter engine
+** How to run TestNG tests within the JUnit Platform
 
   You can run TestNG tests combined with JUnit5 tests.
 
   For more information see this
-  {{{https://github.com/apache/maven-surefire/tree/master/surefire-its/src/test/resources/junit5-testng}example}}.
+  {{{https://github.com/junit-team/testng-engine}TestNG Engine for the JUnit Platform}}.
 
 +---+
 <dependencies>
+
     <dependency>
         <groupId>org.testng</groupId>
         <artifactId>testng</artifactId>
-        <version>7.1.0</version>
+        <version>7.4.0</version>
         <scope>test</scope>
     </dependency>
     <dependency>
-        <groupId>com.github.testng-team</groupId>
-        <artifactId>testng-junit5</artifactId>
-        <version>0.0.1</version>
+        <groupId>org.junit.support</groupId>
+        <artifactId>testng-engine</artifactId>
+        <version>1.0.1</version>
         <scope>test</scope>
-        <exclusions>
-            <exclusion>
-                <groupId>org.junit.platform</groupId>
-                <artifactId>junit-platform-engine</artifactId>
-            </exclusion>
-        </exclusions>
     </dependency>
     <dependency>
         <groupId>org.junit.jupiter</groupId>
         <artifactId>junit-jupiter-api</artifactId>
-        <version>5.6.2</version>
+        <version>5.8.2</version>
         <scope>test</scope>
     </dependency>
 </dependencies>
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 3e7e056..b501404 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
@@ -94,6 +94,17 @@ public class Surefire1787JUnit5IT extends SurefireJUnit4IntegrationTestCase
     }
 
     @Test
+    public void testNgOnlyWithJUnitPlatform()
+    {
+        unpack( "junit5-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" )
@@ -104,7 +115,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-only/pom.xml b/surefire-its/src/test/resources/junit5-testng-only/pom.xml
new file mode 100644
index 0000000..6c19fd9
--- /dev/null
+++ b/surefire-its/src/test/resources/junit5-testng-only/pom.xml
@@ -0,0 +1,64 @@
+<?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>testng-only-junit5</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <description>Project with only TestNG tests executed by JUnit Platform</description>
+
+  <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.testng</groupId>
+      <artifactId>testng</artifactId>
+      <version>7.4.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.support</groupId>
+      <artifactId>testng-engine</artifactId>
+      <version>1.0.1</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-surefire-plugin</artifactId>
+          <version>${surefire.version}</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+
+</project>
diff --git a/surefire-its/src/test/resources/junit5-testng-only/src/test/java/pkg/TestNGTest.java b/surefire-its/src/test/resources/junit5-testng-only/src/test/java/pkg/TestNGTest.java
new file mode 100644
index 0000000..5b2443d
--- /dev/null
+++ b/surefire-its/src/test/resources/junit5-testng-only/src/test/java/pkg/TestNGTest.java
@@ -0,0 +1,10 @@
+package pkg;
+
+import org.testng.annotations.Test;
+
+public class TestNGTest {
+    @Test
+    public void test() {
+
+    }
+}
diff --git a/surefire-its/src/test/resources/junit5-testng/pom.xml b/surefire-its/src/test/resources/junit5-testng/pom.xml
index c18e464..06ec53b 100644
--- a/surefire-its/src/test/resources/junit5-testng/pom.xml
+++ b/surefire-its/src/test/resources/junit5-testng/pom.xml
@@ -21,74 +21,73 @@
 <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>
+  <modelVersion>4.0.0</modelVersion>
 
-    <groupId>org.example</groupId>
-    <artifactId>testng-junit5</artifactId>
-    <version>1.0-SNAPSHOT</version>
+  <groupId>org.example</groupId>
+  <artifactId>testng-junit5</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>
+  <description>Project with mixed TestNG and JUnit5 tests.</description>
 
-    <dependencies>
+  <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.testng</groupId>
+      <artifactId>testng</artifactId>
+      <version>7.4.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.support</groupId>
+      <artifactId>testng-engine</artifactId>
+      <version>1.0.1</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-surefire-plugin</artifactId>
+          <version>${surefire.version}</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+
+  <profiles>
+    <profile>
+      <id>junit5-engine</id>
+      <dependencies>
         <dependency>
-            <groupId>org.testng</groupId>
-            <artifactId>testng</artifactId>
-            <version>7.1.0</version>
-            <scope>test</scope>
+          <groupId>org.junit.jupiter</groupId>
+          <artifactId>junit-jupiter-engine</artifactId>
+          <!-- TODO check with next version of testng-engine -->
+          <!-- we have old junit-platform-commons:1.7.2 in dependency tree -->
+          <version>5.7.2</version>
+          <scope>test</scope>
         </dependency>
+      </dependencies>
+    </profile>
+    <profile>
+      <id>junit5-api</id>
+      <dependencies>
         <dependency>
-            <groupId>com.github.testng-team</groupId>
-            <artifactId>testng-junit5</artifactId>
-            <version>0.0.1</version>
-            <scope>test</scope>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.junit.platform</groupId>
-                    <artifactId>junit-platform-engine</artifactId>
-                </exclusion>
-            </exclusions>
+          <groupId>org.junit.jupiter</groupId>
+          <artifactId>junit-jupiter-api</artifactId>
+          <!-- junit-jupiter-api has junit-platform-commons as nearest definition -->
+          <!-- so junit-platform-commons:1.8.2 wins ;-) -->
+          <version>5.8.2</version>
+          <scope>test</scope>
         </dependency>
-    </dependencies>
-
-    <build>
-        <pluginManagement>
-            <plugins>
-                <plugin>
-                    <groupId>org.apache.maven.plugins</groupId>
-                    <artifactId>maven-surefire-plugin</artifactId>
-                    <version>${surefire.version}</version>
-                </plugin>
-            </plugins>
-        </pluginManagement>
-    </build>
-
-    <profiles>
-        <profile>
-            <id>junit5-engine</id>
-            <dependencies>
-                <dependency>
-                    <groupId>org.junit.jupiter</groupId>
-                    <artifactId>junit-jupiter-engine</artifactId>
-                    <version>5.6.2</version>
-                    <scope>test</scope>
-                </dependency>
-            </dependencies>
-        </profile>
-        <profile>
-            <id>junit5-api</id>
-            <dependencies>
-                <dependency>
-                    <groupId>org.junit.jupiter</groupId>
-                    <artifactId>junit-jupiter-api</artifactId>
-                    <version>5.6.2</version>
-                    <scope>test</scope>
-                </dependency>
-            </dependencies>
-        </profile>
-    </profiles>
+      </dependencies>
+    </profile>
+  </profiles>
 
 </project>