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-script-interpreter.git


The following commit(s) were added to refs/heads/master by this push:
     new 743a913  Make failed Groovy test assert the exception
743a913 is described below

commit 743a91397b749ae1d9c2457f7e645f41757ac8b4
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Thu Nov 19 00:54:39 2026 +0100

    Make failed Groovy test assert the exception
---
 .../shared/scriptinterpreter/ScriptRunnerTest.java      | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git 
a/src/test/java/org/apache/maven/shared/scriptinterpreter/ScriptRunnerTest.java 
b/src/test/java/org/apache/maven/shared/scriptinterpreter/ScriptRunnerTest.java
index 329770a..c3e87a4 100644
--- 
a/src/test/java/org/apache/maven/shared/scriptinterpreter/ScriptRunnerTest.java
+++ 
b/src/test/java/org/apache/maven/shared/scriptinterpreter/ScriptRunnerTest.java
@@ -31,7 +31,9 @@ import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.ValueSource;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
 
@@ -196,12 +198,15 @@ class ScriptRunnerTest {
 
         try (FileLogger fileLogger = new FileLogger(logFile, mirrorHandler);
                 ScriptRunner scriptRunner = new ScriptRunner()) {
-            scriptRunner.run("test", new 
File("src/test/resources/groovy-test"), "failed", buildContext(), fileLogger);
-        } catch (ScriptEvaluationException expected) {
-            String logContent = new 
String(Files.readAllBytes(logFile.toPath()));
-            assertTrue(logContent.contains(new 
File("src/test/resources/groovy-test/failed.groovy").getPath()));
-            assertEquals(logContent, mirrorHandler.getLoggedMessage());
+            assertThrows(
+                    ScriptEvaluationException.class,
+                    () -> scriptRunner.run(
+                            "test", new 
File("src/test/resources/groovy-test"), "failed", buildContext(), fileLogger));
         }
+
+        String logContent = new String(Files.readAllBytes(logFile.toPath()));
+        assertTrue(logContent.contains(new 
File("src/test/resources/groovy-test/failed.groovy").getPath()));
+        assertEquals(logContent, mirrorHandler.getLoggedMessage());
     }
 
     @Test
@@ -215,7 +220,7 @@ class ScriptRunnerTest {
                     "test", new File("src/test/resources/groovy-test"), 
"return-false", buildContext(), fileLogger);
             fail();
         } catch (ScriptReturnException expected) {
-            assertEquals(false, expected.getResult());
+            assertFalse((Boolean) expected.getResult());
             assertEquals("The test returned false.", expected.getMessage());
             String logContent = new 
String(Files.readAllBytes(logFile.toPath()));
             assertTrue(logContent.contains(new 
File("src/test/resources/groovy-test/return-false.groovy").getPath()));

Reply via email to