You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2026/09/19 22:25:54 UTC

(maven-verifier) branch master updated: Drop Hamcrest from tests

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

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-verifier.git


The following commit(s) were added to refs/heads/master by this push:
     new a4168b4  Drop Hamcrest from tests
a4168b4 is described below

commit a4168b45d7c529e96ec1300d7f637b1425de1de5
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sat Sep 19 23:51:36 2026 +0200

    Drop Hamcrest from tests
---
 pom.xml                                            |  6 ---
 .../shared/verifier/Embedded3xLauncherTest.java    |  9 ++--
 .../maven/shared/verifier/ForkedLauncherTest.java  |  7 ++--
 .../apache/maven/shared/verifier/VerifierTest.java | 48 +++++++++++-----------
 4 files changed, 30 insertions(+), 40 deletions(-)

diff --git a/pom.xml b/pom.xml
index 94006f1..237b894 100644
--- a/pom.xml
+++ b/pom.xml
@@ -108,12 +108,6 @@
       <artifactId>junit-jupiter-params</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.hamcrest</groupId>
-      <artifactId>hamcrest-core</artifactId>
-      <version>3.0</version>
-      <scope>test</scope>
-    </dependency>
     <!-- embedder for testing Embedded3xLauncher with classpath -->
     <dependency>
       <groupId>org.apache.maven</groupId>
diff --git a/src/test/java/org/apache/maven/shared/verifier/Embedded3xLauncherTest.java b/src/test/java/org/apache/maven/shared/verifier/Embedded3xLauncherTest.java
index e6621de..796a550 100644
--- a/src/test/java/org/apache/maven/shared/verifier/Embedded3xLauncherTest.java
+++ b/src/test/java/org/apache/maven/shared/verifier/Embedded3xLauncherTest.java
@@ -26,8 +26,7 @@ import java.util.Properties;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.io.TempDir;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 @SuppressWarnings("deprecation")
 public class Embedded3xLauncherTest {
@@ -54,9 +53,9 @@ public class Embedded3xLauncherTest {
 
         int exitCode = launcher.run(new String[] {"clean"}, new Properties(), workingDir, logFile.toFile());
 
-        assertThat(
-                "exit code unexpected, build log: " + System.lineSeparator() + new String(Files.readAllBytes(logFile)),
+        assertEquals(
+                0,
                 exitCode,
-                is(0));
+                "exit code unexpected, build log: " + System.lineSeparator() + new String(Files.readAllBytes(logFile)));
     }
 }
diff --git a/src/test/java/org/apache/maven/shared/verifier/ForkedLauncherTest.java b/src/test/java/org/apache/maven/shared/verifier/ForkedLauncherTest.java
index 336604d..e46d05c 100644
--- a/src/test/java/org/apache/maven/shared/verifier/ForkedLauncherTest.java
+++ b/src/test/java/org/apache/maven/shared/verifier/ForkedLauncherTest.java
@@ -32,8 +32,7 @@ import java.util.Properties;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.io.TempDir;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.fail;
 
 @SuppressWarnings("deprecation")
@@ -56,7 +55,7 @@ public class ForkedLauncherTest {
         // most likely this contains the exception in case exitCode != 0
         expectFileLine(logFile, "Hello World");
 
-        assertThat("exit code", exitCode, is(0));
+        assertEquals(0, exitCode, "exit code");
     }
 
     @Test
@@ -69,7 +68,7 @@ public class ForkedLauncherTest {
         // most likely this contains the exception in case exitCode != 0
         expectFileLine(logFile, "Hello World");
 
-        assertThat("exit code", exitCode, is(0));
+        assertEquals(0, exitCode, "exit code");
     }
 
     static void expectFileLine(Path file, String expectedline) throws IOException {
diff --git a/src/test/java/org/apache/maven/shared/verifier/VerifierTest.java b/src/test/java/org/apache/maven/shared/verifier/VerifierTest.java
index a166942..4e675a5 100644
--- a/src/test/java/org/apache/maven/shared/verifier/VerifierTest.java
+++ b/src/test/java/org/apache/maven/shared/verifier/VerifierTest.java
@@ -38,12 +38,7 @@ import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.Arguments;
 import org.junit.jupiter.params.provider.MethodSource;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.allOf;
-import static org.hamcrest.Matchers.arrayContaining;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.hasItem;
-import static org.hamcrest.Matchers.hasItemInArray;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -159,14 +154,15 @@ public class VerifierTest {
         verifier.executeGoal("test");
         verifier.resetStreams();
 
-        assertThat(
-                verifier.launcher.cliArgs,
-                arrayContaining(
-                        "-e",
-                        "--batch-mode",
-                        "-Dmaven.repo.local=test-local-repo",
-                        "org.apache.maven.plugins:maven-clean-plugin:clean",
-                        "test"));
+        assertArrayEquals(
+                new String[] {
+                    "-e",
+                    "--batch-mode",
+                    "-Dmaven.repo.local=test-local-repo",
+                    "org.apache.maven.plugins:maven-clean-plugin:clean",
+                    "test"
+                },
+                verifier.launcher.cliArgs);
     }
 
     @Test
@@ -177,14 +173,15 @@ public class VerifierTest {
         verifier.execute();
         verifier.resetStreams();
 
-        assertThat(
-                verifier.launcher.cliArgs,
-                arrayContaining(
-                        "-e",
-                        "--batch-mode",
-                        "-Dmaven.repo.local=test-local-repo",
-                        "org.apache.maven.plugins:maven-clean-plugin:clean",
-                        "test"));
+        assertArrayEquals(
+                new String[] {
+                    "-e",
+                    "--batch-mode",
+                    "-Dmaven.repo.local=test-local-repo",
+                    "org.apache.maven.plugins:maven-clean-plugin:clean",
+                    "test"
+                },
+                verifier.launcher.cliArgs);
     }
 
     public static Stream<Arguments> argumentsForTest() {
@@ -203,7 +200,7 @@ public class VerifierTest {
         verifier.executeGoal("test");
         verifier.resetStreams();
 
-        assertThat(verifier.launcher.cliArgs, hasItemInArray(expectedArgument));
+        assertTrue(Arrays.asList(verifier.launcher.cliArgs).contains(expectedArgument));
     }
 
     @Test
@@ -214,7 +211,8 @@ public class VerifierTest {
         verifier.executeGoal("test");
         verifier.resetStreams();
 
-        assertThat(verifier.launcher.cliArgs, allOf(hasItemInArray("cliArg1"), hasItemInArray("cliArg2")));
+        List<String> cliArgs = Arrays.asList(verifier.launcher.cliArgs);
+        assertTrue(cliArgs.contains("cliArg1") && cliArgs.contains("cliArg2"));
     }
 
     @Test
@@ -238,7 +236,7 @@ public class VerifierTest {
             verifier.execute();
             List<String> logs = Files.readAllLines(tmp.toPath());
 
-            assertThat("Maven logs not in log file", logs, hasItem(containsString("BUILD SUCCESS")));
+            assertTrue(logs.stream().anyMatch(line -> line.contains("BUILD SUCCESS")), "Maven logs not in log file");
         } finally {
             Files.deleteIfExists(tmp.toPath());
         }