Skip to content

Collapse consecutive AssertJ assertThat(..) statements that each use the same object to a single statement #373

@timtebeek

Description

@timtebeek

What problem are you trying to solve?

What precondition(s) should be checked before applying this recipe?

Only consecutive calls; not when interleaved with others.
Only when the asserted object does not change; so for instance no calls to extracting("baz"), as that would change the semantics.

Describe the situation before applying the recipe

assertThat(listA).isNotNull();
assertThat(listA).hasSize(3);
assertThat(listA).containsExactly("a", "b", "c");

Describe the situation after applying the recipe

assertThat(listA)
    .isNotNull()
    .hasSize(3)
    .containsExactly("a", "b", "c");

Any additional context

Would help clean up after the migration from Hamcrest allOf(Matcher...) to individual statements.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions