AssertJ `containsExactly` assertion on list with wildcard
问题 I have a getter returning a List with a wildcard: import java.util.List; public interface Foo { List<? extends Bar> getList(); } Where Bar is an other interface. When I write an assertion with AssertJ like this: assertThat(foo.getList()).containsExactly(bar1, bar3); EDIT: my complete usage is to chain a usingElementComparator and to provide a Comparator<Bar> to compare the expected Bar instances. Comparator<Bar> comparator = createBarComparator() assertThat(foo.getList())