0
我有串的隊列,我想2級的匹配在一個斷言 結合(簡化)的代碼是這樣的編譯錯誤匹配器
Queue<String> strings = new LinkedList<>();
assertThat(strings, both(hasSize(1)).and(hasItem("Some string")));
但是當我編譯我得到以下信息:
incompatible types: no instance(s) of type variable(s) T exist so that org.hamcrest.Matcher<java.lang.Iterable<? super T>> conforms to org.hamcrest.Matcher<? super java.util.Collection<? extends java.lang.Object>>
- hasItem返回
Matcher<Iterable<? super T>>
- hasSize返回
Matcher<Collection<? extends E>>
我該如何解決這個問題?