-
-
Notifications
You must be signed in to change notification settings - Fork 765
Milestone
Description
Right now, there is no nice way to call asInstanceOf when a Set instance is expected.
Current solutions:
Object actual = Set.of("first", "second");
assertThat(actual)
.asInstanceOf(InstanceOfAssertFactories.type(Set.class))
.satisfies(set -> assertThat(set).containsExactly("first", "second")); // unchecked warning
assertThat(actual)
.asInstanceOf(InstanceOfAssertFactories.COLLECTION) // no implicit `isInstanceOf(Set.class)`
.containsExactly("first", "second"));
assertThat(map.get("value"))
.asInstanceOf(new InstanceOfAssertFactory<>(Set.class, Assertions::<String> assertThat)) // verbose
.containsExactly("first", "second");By design, we didn't introduce any InstanceOfAssertFactory for types that don't have more specific assertions, i.e., there is no AbstractSetAssert today because it wouldn't have any added value compared to AbstractCollectionAssert.
We should investigate how to improve such use cases.
sbrannen
Metadata
Metadata
Assignees
Labels
No labels