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 fcf1f3cc3 Use JUnit5 in failsafe ITs
fcf1f3cc3 is described below
commit fcf1f3cc34bf84c8f3caf3f3754d270a0e87e25a
Author: Slawomir Jaranowski <[email protected]>
AuthorDate: Wed Feb 4 00:31:04 2026 +0100
Use JUnit5 in failsafe ITs
also improvements to use artifacts from current build reactor
now ITs download artifacts from snapshot repository, which is available by
parent pom
---
maven-failsafe-plugin/pom.xml | 16 +++++++++
.../src/it/jetty-war-test-failing/pom.xml | 6 ++--
.../src/test/java/basic/BasicIT.java | 38 +++++++++++-----------
.../src/it/jetty-war-test-passing/pom.xml | 6 ++--
.../src/test/java/basic/BasicIT.java | 38 +++++++++++-----------
.../src/it/multiple-summaries-failing/pom.xml | 6 ++--
.../src/test/java/MyAT.java | 14 ++++----
.../src/test/java/MyIT.java | 14 ++++----
.../src/it/multiple-summaries/pom.xml | 6 ++--
.../it/multiple-summaries/src/test/java/MyIT.java | 14 ++++----
maven-failsafe-plugin/src/it/settings.xml | 35 ++++++++++++++++++--
.../src/it/working-directory/pom.xml | 6 ++--
.../it/working-directory/src/test/java/MyIT.java | 14 ++++----
13 files changed, 130 insertions(+), 83 deletions(-)
diff --git a/maven-failsafe-plugin/pom.xml b/maven-failsafe-plugin/pom.xml
index 4d83c69dd..5a2ea4ecc 100644
--- a/maven-failsafe-plugin/pom.xml
+++ b/maven-failsafe-plugin/pom.xml
@@ -108,6 +108,16 @@
<scope>provided</scope>
</dependency>
+ <!-- dependencies for ITs, will be copied to local-repo as extra artifacts
-->
+ <!-- without it, artifact will be downloaded from remote repository -->
+ <!-- add here to use artifact from project build reactor, not last
installed to local repository -->
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-junit-platform</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
@@ -256,6 +266,11 @@
</goals>
<phase>pre-integration-test</phase>
<configuration>
+
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
+ <extraArtifacts>
+
<artifact>org.apache.maven.surefire:surefire-junit-platform:${project.version}</artifact>
+
<artifact>org.junit.jupiter:junit-jupiter-api:${versions.junit5}</artifact>
+ </extraArtifacts>
<skipInstallation>${skipTests}</skipInstallation>
</configuration>
</execution>
@@ -265,6 +280,7 @@
<goal>run</goal>
</goals>
<configuration>
+
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
<projectsDirectory>src/it</projectsDirectory>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<goals>
diff --git a/maven-failsafe-plugin/src/it/jetty-war-test-failing/pom.xml
b/maven-failsafe-plugin/src/it/jetty-war-test-failing/pom.xml
index 4ba78cdaf..a4b26201b 100644
--- a/maven-failsafe-plugin/src/it/jetty-war-test-failing/pom.xml
+++ b/maven-failsafe-plugin/src/it/jetty-war-test-failing/pom.xml
@@ -34,9 +34,9 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.2</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>@versions.junit5@</version>
<scope>test</scope>
</dependency>
<dependency>
diff --git
a/maven-failsafe-plugin/src/it/jetty-war-test-failing/src/test/java/basic/BasicIT.java
b/maven-failsafe-plugin/src/it/jetty-war-test-failing/src/test/java/basic/BasicIT.java
index deb88709e..2d6abf801 100644
---
a/maven-failsafe-plugin/src/it/jetty-war-test-failing/src/test/java/basic/BasicIT.java
+++
b/maven-failsafe-plugin/src/it/jetty-war-test-failing/src/test/java/basic/BasicIT.java
@@ -24,11 +24,14 @@
import org.htmlunit.WebClient;
import org.htmlunit.html.HtmlPage;
-import junit.framework.TestCase;
-public class BasicIT
- extends TestCase
-{
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+
+public class BasicIT {
private WebClient client;
@@ -36,28 +39,25 @@ public class BasicIT
private final Properties properties = new Properties();
- public void setUp()
- throws IOException
- {
+ @BeforeEach
+ public void setUp() throws IOException {
client = new WebClient();
- properties.load( getClass().getResourceAsStream(
"/integration-test.properties" ) );
- baseUrl = properties.getProperty( "baseUrl" );
+
properties.load(getClass().getResourceAsStream("/integration-test.properties"));
+ baseUrl = properties.getProperty("baseUrl");
}
- public void tearDown()
- {
- if ( client != null )
- {
+ @AfterEach
+ public void tearDown() {
+ if (client != null) {
client.close();
client = null;
}
}
- public void testSmokes()
- throws Exception
- {
- client.getOptions().setThrowExceptionOnFailingStatusCode( false );
- HtmlPage page = client.getPage( baseUrl + "index.html" );
- assertFalse( page.asNormalizedText().contains( "Hello World" ) );
+ @Test
+ public void testSmokes() throws Exception {
+ client.getOptions().setThrowExceptionOnFailingStatusCode(false);
+ HtmlPage page = client.getPage(baseUrl + "index.html");
+ assertFalse(page.asNormalizedText().contains("Hello World"));
}
}
diff --git a/maven-failsafe-plugin/src/it/jetty-war-test-passing/pom.xml
b/maven-failsafe-plugin/src/it/jetty-war-test-passing/pom.xml
index c159eec72..c81a06412 100644
--- a/maven-failsafe-plugin/src/it/jetty-war-test-passing/pom.xml
+++ b/maven-failsafe-plugin/src/it/jetty-war-test-passing/pom.xml
@@ -34,9 +34,9 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.2</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>@versions.junit5@</version>
<scope>test</scope>
</dependency>
<dependency>
diff --git
a/maven-failsafe-plugin/src/it/jetty-war-test-passing/src/test/java/basic/BasicIT.java
b/maven-failsafe-plugin/src/it/jetty-war-test-passing/src/test/java/basic/BasicIT.java
index 2365a1203..898f2e012 100644
---
a/maven-failsafe-plugin/src/it/jetty-war-test-passing/src/test/java/basic/BasicIT.java
+++
b/maven-failsafe-plugin/src/it/jetty-war-test-passing/src/test/java/basic/BasicIT.java
@@ -23,11 +23,14 @@
import org.htmlunit.WebClient;
import org.htmlunit.html.HtmlPage;
-import junit.framework.TestCase;
-public class BasicIT
- extends TestCase
-{
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class BasicIT {
private WebClient client;
@@ -35,28 +38,25 @@ public class BasicIT
private final Properties properties = new Properties();
- public void setUp()
- throws IOException
- {
+ @BeforeEach
+ public void setUp() throws IOException {
client = new WebClient();
- properties.load( getClass().getResourceAsStream(
"/integration-test.properties" ) );
- baseUrl = properties.getProperty( "baseUrl" );
+
properties.load(getClass().getResourceAsStream("/integration-test.properties"));
+ baseUrl = properties.getProperty("baseUrl");
}
- public void tearDown()
- {
- if ( client != null )
- {
+ @AfterEach
+ public void tearDown() {
+ if (client != null) {
client.close();
client = null;
}
}
- public void testSmokes()
- throws Exception
- {
- client.getOptions().setThrowExceptionOnFailingStatusCode( false );
- HtmlPage page = client.getPage( baseUrl + "index.html" );
- assertTrue( page.asNormalizedText().contains( "Hello World" ) );
+ @Test
+ public void testSmokes() throws Exception {
+ client.getOptions().setThrowExceptionOnFailingStatusCode(false);
+ HtmlPage page = client.getPage(baseUrl + "index.html");
+ assertTrue(page.asNormalizedText().contains("Hello World"));
}
}
diff --git a/maven-failsafe-plugin/src/it/multiple-summaries-failing/pom.xml
b/maven-failsafe-plugin/src/it/multiple-summaries-failing/pom.xml
index caef8e1af..5e1f835f6 100644
--- a/maven-failsafe-plugin/src/it/multiple-summaries-failing/pom.xml
+++ b/maven-failsafe-plugin/src/it/multiple-summaries-failing/pom.xml
@@ -33,9 +33,9 @@
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.2</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>@versions.junit5@</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git
a/maven-failsafe-plugin/src/it/multiple-summaries-failing/src/test/java/MyAT.java
b/maven-failsafe-plugin/src/it/multiple-summaries-failing/src/test/java/MyAT.java
index 00d1e7e57..6a718c796 100644
---
a/maven-failsafe-plugin/src/it/multiple-summaries-failing/src/test/java/MyAT.java
+++
b/maven-failsafe-plugin/src/it/multiple-summaries-failing/src/test/java/MyAT.java
@@ -17,13 +17,13 @@
* under the License.
*/
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Test;
-public class MyAT
- extends TestCase
-{
- public void testSomething()
- {
- assertTrue( false );
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class MyAT {
+ @Test
+ public void testSomething() {
+ assertTrue(false);
}
}
diff --git
a/maven-failsafe-plugin/src/it/multiple-summaries-failing/src/test/java/MyIT.java
b/maven-failsafe-plugin/src/it/multiple-summaries-failing/src/test/java/MyIT.java
index 59000d500..1a530f064 100644
---
a/maven-failsafe-plugin/src/it/multiple-summaries-failing/src/test/java/MyIT.java
+++
b/maven-failsafe-plugin/src/it/multiple-summaries-failing/src/test/java/MyIT.java
@@ -17,13 +17,13 @@
* under the License.
*/
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Test;
-public class MyIT
- extends TestCase
-{
- public void testSomething()
- {
- assertTrue( true );
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class MyIT {
+ @Test
+ public void testSomething() {
+ assertTrue(true);
}
}
diff --git a/maven-failsafe-plugin/src/it/multiple-summaries/pom.xml
b/maven-failsafe-plugin/src/it/multiple-summaries/pom.xml
index 5381e0750..6cde7dcbe 100644
--- a/maven-failsafe-plugin/src/it/multiple-summaries/pom.xml
+++ b/maven-failsafe-plugin/src/it/multiple-summaries/pom.xml
@@ -33,9 +33,9 @@
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.2</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>@versions.junit5@</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git
a/maven-failsafe-plugin/src/it/multiple-summaries/src/test/java/MyIT.java
b/maven-failsafe-plugin/src/it/multiple-summaries/src/test/java/MyIT.java
index 59000d500..1a530f064 100644
--- a/maven-failsafe-plugin/src/it/multiple-summaries/src/test/java/MyIT.java
+++ b/maven-failsafe-plugin/src/it/multiple-summaries/src/test/java/MyIT.java
@@ -17,13 +17,13 @@
* under the License.
*/
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Test;
-public class MyIT
- extends TestCase
-{
- public void testSomething()
- {
- assertTrue( true );
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class MyIT {
+ @Test
+ public void testSomething() {
+ assertTrue(true);
}
}
diff --git a/maven-failsafe-plugin/src/it/settings.xml
b/maven-failsafe-plugin/src/it/settings.xml
index 90ecf59e1..23327616e 100644
--- a/maven-failsafe-plugin/src/it/settings.xml
+++ b/maven-failsafe-plugin/src/it/settings.xml
@@ -18,5 +18,36 @@
~ under the License.
-->
<settings>
- <localRepository>@localRepositoryUrl@</localRepository>
-</settings>
+ <profiles>
+ <profile>
+ <id>it-repo</id>
+ <repositories>
+ <repository>
+ <id>local.central</id>
+ <url>@localRepositoryUrl@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>local.central</id>
+ <url>@localRepositoryUrl@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+ </profile>
+ </profiles>
+ <activeProfiles>
+ <activeProfile>it-repo</activeProfile>
+ </activeProfiles>
+</settings>
\ No newline at end of file
diff --git a/maven-failsafe-plugin/src/it/working-directory/pom.xml
b/maven-failsafe-plugin/src/it/working-directory/pom.xml
index 0277c2225..4a70dceeb 100644
--- a/maven-failsafe-plugin/src/it/working-directory/pom.xml
+++ b/maven-failsafe-plugin/src/it/working-directory/pom.xml
@@ -33,9 +33,9 @@
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.2</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>@versions.junit5@</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git
a/maven-failsafe-plugin/src/it/working-directory/src/test/java/MyIT.java
b/maven-failsafe-plugin/src/it/working-directory/src/test/java/MyIT.java
index 59000d500..1a530f064 100644
--- a/maven-failsafe-plugin/src/it/working-directory/src/test/java/MyIT.java
+++ b/maven-failsafe-plugin/src/it/working-directory/src/test/java/MyIT.java
@@ -17,13 +17,13 @@
* under the License.
*/
-import junit.framework.TestCase;
+import org.junit.jupiter.api.Test;
-public class MyIT
- extends TestCase
-{
- public void testSomething()
- {
- assertTrue( true );
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class MyIT {
+ @Test
+ public void testSomething() {
+ assertTrue(true);
}
}