This matches checks for a collection of matches and succeeds if they all succeed.
The signature reads:
public static <T> Matcher<T> allOf(Iterable<Matcher<? extends T>> matchers)
Why does it do iterability
Matcher<? extends T>
and not
Matcher<? super t>
If this is correct, please explain.
The type will be inferred from the mapped (tested) object, so I expect that iterability will contain matches that are compatible with the matching object or with any superclass of it. Similarly, letting iterable hold matches only compatible with the subclass seems wrong.
source
share