Skip to content

Delegate assertTrue/assertFalse/fail to AssertJ#21

Merged
juherr merged 1 commit into
port-assertj-delegationfrom
delegate-boolean-fail-assertj
Jun 28, 2026
Merged

Delegate assertTrue/assertFalse/fail to AssertJ#21
juherr merged 1 commit into
port-assertj-delegationfrom
delegate-boolean-fail-assertj

Conversation

@juherr

@juherr juherr commented Jun 28, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up to #20 (stacked on it — base is port-assertj-delegation). Extends the AssertJ
delegation to the remaining behaviour-identical entry points:

  • assertTrue / assertFalseassertThat(condition).as(message).isTrue() / .isFalse()
  • fail(message) and fail(message, cause)org.assertj.core.api.Assertions.fail(...)

Because the OO Assertion / SoftAssert wrappers delegate to org.testng.Assert, soft
assertions now use AssertJ for these checks too
— no change needed in Assertion/SoftAssert
themselves. Only the failure-message text changes; pass/fail behaviour is identical.

Test updates (message-format only)

The AssertJ messages differ from TestNG's (and are multi-line), so four message-sensitive tests
were updated — behaviour assertions are unchanged:

  • AssertTest#testAssertTrueMessage / testAssertFalseMessage — regexps now match AssertJ output
    ([msg] \nExpecting value to be true but was false).
  • AssertionTest#test2_fails — regexp updated to the [Raw test] … AssertJ form.
  • SoftAssertTest#testAssertAllCount — no longer counts report lines (AssertJ messages span
    multiple lines); it now asserts the failed assertion's message is reported exactly once, which
    preserves the original "one failure → reported once" intent.

Notes

  • fail is the shared failure sink for the (deliberately non-delegated) assertEquals / collection
    assertions. Delegating it routes those through AssertJ's AssertionFailedError (a subclass of
    AssertionError) — the message text is still TestNG's (built by format(...)), only the
    exception subtype changes. The full suite confirms no assertEquals/collection test regressed.
  • assertEquals / assertNotEquals / collection / array / expectThrows remain on TestNG's own
    implementation (unchanged scope vs Back org.testng.Assert with AssertJ for behaviour-identical assertions #20).

Testing

  • ./mvnw clean testBUILD SUCCESS, Tests run: 181, Failures: 0, Errors: 0, Skipped: 1.

🤖 Generated with Claude Code

Follow-up to the AssertJ delegation: extend it to the remaining
behaviour-identical entry points.

- assertTrue/assertFalse -> assertThat(condition).as(message).isTrue()/isFalse()
- fail(message) and fail(message, cause) -> org.assertj.core.api.Assertions.fail(...)

These flow through the OO Assertion/SoftAssert wrappers automatically
(they delegate to org.testng.Assert), so soft assertions now use AssertJ
for these checks too. Only the failure-message text changes; the
pass/fail behaviour is unchanged.

Updated the message-format-sensitive tests accordingly:
- assertTrue/assertFalse message regexps now match AssertJ's output.
- SoftAssertTest#testAssertAllCount no longer counts report lines (AssertJ
  messages are multi-line); it asserts the failed message is reported once.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@juherr juherr requested a review from krmahadevan June 28, 2026 15:37
@juherr juherr merged commit c67808e into port-assertj-delegation Jun 28, 2026
1 check passed
@juherr juherr deleted the delegate-boolean-fail-assertj branch June 28, 2026 15:38
@juherr juherr removed the request for review from krmahadevan June 28, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant