-
-
Notifications
You must be signed in to change notification settings - Fork 749
Closed
Closed
Copy link
Milestone
Description
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.
Metadata
Metadata
Assignees
Labels
No labels