Is Hamcrest allOf () signature incorrect?

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.

+3
source share
1 answer

(answer to your own question)

- . 2007 Hamcrest 1.2. "extends" JUnit JUnit 4.11, 2012 .

+4

All Articles