From 9a8879704ce547dfc3fbaf2b6a25aa9000346ad8 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 26 Mar 2022 15:40:41 +0100 Subject: [PATCH 1/2] [SUREFIRE-2024] Replace testng-junit5 by testng-engine --- .../site/apt/examples/junit-platform.apt.vm | 21 ++- .../src/test/resources/junit5-testng/pom.xml | 124 +++++++++--------- 2 files changed, 70 insertions(+), 75 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 5c02c6d1c8..b413e58379 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 @@ -349,37 +349,32 @@ Using JUnit 5 Platform +---+ -** 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/apache/maven-surefire/tree/master/surefire-its/src/test/resources/junit5-testng}example}} + and {{{https://github.com/junit-team/testng-engine}TestNG Engine for the JUnit Platform}}. +---+ org.testng testng - 7.1.0 + 7.4.0 test - com.github.testng-team - testng-junit5 - 0.0.1 + org.junit.support + testng-engine + 1.0.1 test - - - org.junit.platform - junit-platform-engine - - org.junit.jupiter junit-jupiter-api - 5.6.2 + 5.8.2 test diff --git a/surefire-its/src/test/resources/junit5-testng/pom.xml b/surefire-its/src/test/resources/junit5-testng/pom.xml index c18e4649c6..2f8cf9d5ab 100644 --- a/surefire-its/src/test/resources/junit5-testng/pom.xml +++ b/surefire-its/src/test/resources/junit5-testng/pom.xml @@ -21,74 +21,74 @@ - 4.0.0 + 4.0.0 - org.example - testng-junit5 - 1.0-SNAPSHOT + org.example + testng-junit5 + 1.0-SNAPSHOT - - UTF-8 - ${java.specification.version} - ${java.specification.version} - + Project with mixed TestNG and JUnit5 tests. - + + UTF-8 + ${java.specification.version} + ${java.specification.version} + + + + + org.testng + testng + 7.4.0 + test + + + org.junit.support + testng-engine + 1.0.1 + test + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.version} + + + + + + + + junit5-engine + - org.testng - testng - 7.1.0 - test + org.junit.jupiter + junit-jupiter-engine + + + 5.7.2 + test + + + + junit5-api + - com.github.testng-team - testng-junit5 - 0.0.1 - test - - - org.junit.platform - junit-platform-engine - - + org.junit.jupiter + junit-jupiter-api + + + 5.8.2 + test - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${surefire.version} - - - - - - - - junit5-engine - - - org.junit.jupiter - junit-jupiter-engine - 5.6.2 - test - - - - - junit5-api - - - org.junit.jupiter - junit-jupiter-api - 5.6.2 - test - - - - + + + From 4444fa3124721875f9422eac1d396649de3ecb1e Mon Sep 17 00:00:00 2001 From: tibordigana Date: Wed, 30 Mar 2022 10:39:20 +0200 Subject: [PATCH 2/2] clarified after discussion, added default profile --- .../site/apt/examples/junit-platform.apt.vm | 8 +--- .../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 b413e58379..26e5f1b1c3 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 1.0.1 test - - org.junit.jupiter - junit-jupiter-api - 5.8.2 - test - +---+ The Maven does not take any responsibility for broken compatibilities in this case and the responsibility for - the dependency <<>>. + the dependency <<>>. ** 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 f64ad702bd..ede3d11b84 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 @@ -96,6 +96,18 @@ public void selectJUnit5() "Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider" ); } + @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() { @@ -107,7 +119,6 @@ public void testNgWithJupiterApi() .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 2f8cf9d5ab..fd383106dc 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 @@ org.testng testng - 7.4.0 + 7.5 test @@ -63,6 +63,23 @@ + + testng-only + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + **/TestNGTest.java + + + + + + junit5-engine @@ -78,6 +95,24 @@ junit5-api + + + + + org.junit.support + testng-engine + + + org.junit.platform + junit-platform-engine + + + + + org.junit.jupiter 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 916eeab5f0..eea7289fd7 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 @@ class JUnit5Test { @Test - public void test() { + void test() { } }