Skip to content

Apply a few assertion best practices#67

Merged
scordio merged 1 commit into
assertj:mainfrom
timtebeek:apply-best-practices
Jun 22, 2026
Merged

Apply a few assertion best practices#67
scordio merged 1 commit into
assertj:mainfrom
timtebeek:apply-best-practices

Conversation

@timtebeek

Copy link
Copy Markdown
Contributor
  • There were some drop in replacements not yet applied, like isCloseTo.
  • A bit of weird formatting in NumberAssertionsExamples where the next assertThat was on the end of the previous line.
  • A missing hasToString instead of ....toString()).isEqualTo(...

@timtebeek

Copy link
Copy Markdown
Contributor Author

I had intentionally left out a few optimization that are redundant, such as the check here on isPresent() in a method chain where the subsequent assertion imply the entry is present:

@Test
public void optional_assertions_examples() {
Optional<String> optional = Optional.of("Test");
assertThat(optional).isPresent()
.containsInstanceOf(String.class)
.contains("Test");

While that could be an improvement in actual use, this repository aims to show the breadth of assertions available, which then makes sense to leave that isPresent() and others in, perhaps. If you feel we can drop those for clarity then let me know.

@timtebeek timtebeek force-pushed the apply-best-practices branch from 4212679 to b69b9a2 Compare June 22, 2026 19:39
@scordio scordio self-assigned this Jun 22, 2026
@timtebeek timtebeek force-pushed the apply-best-practices branch 2 times, most recently from bfb9d86 to 7afb7cd Compare June 22, 2026 19:57
@timtebeek timtebeek force-pushed the apply-best-practices branch from 7afb7cd to 2f041c0 Compare June 22, 2026 20:08
@scordio scordio merged commit 301fc03 into assertj:main Jun 22, 2026
@scordio

scordio commented Jun 22, 2026

Copy link
Copy Markdown
Member

Thanks @timtebeek, and sorry for the delay!

@timtebeek timtebeek deleted the apply-best-practices branch June 23, 2026 06:05
@timtebeek

Copy link
Copy Markdown
Contributor Author

No worries at all! Good to see these merged.

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.

2 participants