Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate assertThat(Iterable, AssertFactory) and assertThat(Iterable, Class) #3453

Closed
scordio opened this issue May 2, 2024 · 0 comments
Closed
Assignees
Milestone

Comments

@scordio
Copy link
Member

scordio commented May 2, 2024

Both assertThat(Iterable, AssertFactory) and assertThat(Iterable, Class) have been added in version 3.5.0 to aid the creation of type-specific assertions for the elements of an Iterable instance.

Today, it's possible to write the following:

Iterable<String> hobbits = Set.of("frodo", "sam", "Pippin");

// with AssertFactory
assertThat(hobbits, StringAssert::new).first()
                                      .startsWith("fro")
                                      .endsWith("do");

// with Class
assertThat(hobbits, StringAssert.class).first()
                                       .startsWith("fro")
                                       .endsWith("do");

However, with the introduction of InstanceOfAssertFactory in version 3.13.0 and the corresponding first(InstanceOfAssertFactory) variant in version 3.14.0, the above can be rewritten as:

assertThat(hobbits).first(STRING) // static import of InstanceOfAssertFactories.STRING
                   .startsWith("fro")
                   .endsWith("do");

The main advantage of the latter is easier discoverability therefore we should deprecate the two assertThat entry points.

@scordio scordio changed the title Deprecate assertThat(Iterable, AssertFactory) and assertThat(Iterable, Class<AbstractAssert>) Deprecate assertThat(Iterable, AssertFactory) and assertThat(Iterable, Class) May 2, 2024
@scordio scordio added this to the 3.26.0 milestone May 2, 2024
@joel-costigliola joel-costigliola self-assigned this May 11, 2024
genuss pushed a commit to genuss/assertj that referenced this issue May 28, 2024
…n(Iterable, Class)

Fix assertj#3453

(cherry picked from commit fd04639640c9ad048e926693c1614dd9b83df224)
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

No branches or pull requests

2 participants