Delegate assertTrue/assertFalse/fail to AssertJ#21
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #20 (stacked on it — base is
port-assertj-delegation). Extends the AssertJdelegation to the remaining behaviour-identical entry points:
assertTrue/assertFalse→assertThat(condition).as(message).isTrue()/.isFalse()fail(message)andfail(message, cause)→org.assertj.core.api.Assertions.fail(...)Because the OO
Assertion/SoftAssertwrappers delegate toorg.testng.Assert, softassertions now use AssertJ for these checks too — no change needed in
Assertion/SoftAssertthemselves. 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 spanmultiple lines); it now asserts the failed assertion's message is reported exactly once, which
preserves the original "one failure → reported once" intent.
Notes
failis the shared failure sink for the (deliberately non-delegated)assertEquals/ collectionassertions. Delegating it routes those through AssertJ's
AssertionFailedError(a subclass ofAssertionError) — the message text is still TestNG's (built byformat(...)), only theexception subtype changes. The full suite confirms no
assertEquals/collection test regressed.assertEquals/assertNotEquals/ collection / array /expectThrowsremain on TestNG's ownimplementation (unchanged scope vs Back org.testng.Assert with AssertJ for behaviour-identical assertions #20).
Testing
./mvnw clean test→ BUILD SUCCESS,Tests run: 181, Failures: 0, Errors: 0, Skipped: 1.🤖 Generated with Claude Code