Skip to content

Make failed Groovy test assert the exception - #234

Draft
slachiewicz wants to merge 1 commit into
apache:masterfrom
slachiewicz:agent/sweep-test-vacuous-groovy
Draft

slachiewicz wants to merge 1 commit into
apache:masterfrom
slachiewicz:agent/sweep-test-vacuous-groovy

Conversation

@slachiewicz

@slachiewicz slachiewicz commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

The failedGroovyShouldCreateProperLogsMessage test caught ScriptEvaluationException but still passed when no exception was thrown, so it did not actually verify the failure path.

  • Wrap the scriptRunner.run(...) call in assertThrows(ScriptEvaluationException.class, ...) and keep both log assertions after it.
  • Replace assertEquals(false, ...) with assertFalse(...) for the returned result, casting to Boolean because getResult() returns Object.
  • No change to the number of test cases (18 in ScriptRunnerTest, 36 in the module).

Tracking: apache/maven#14072

Verified: JAVA_HOME=<JDK 21> mvn -B -o test → 36 tests, 0 failures/errors, BUILD SUCCESS (0 Checkstyle violations). Mutation: making ScriptRunner.run return normally for the failed fixture makes this test fail with "Expected ScriptEvaluationException to be thrown, but nothing was thrown"; the scratch change was restored and the suite re-run green. CI not checked here (driver checks centrally).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant