-2
我嘗試運行這個JUnit測試並最終斷言:爲什麼當比較項目而不是列表時,我會得到'實際和正式的參數列表長度不同'?
ResponseExample responseExample = new ResponseExample();
responseExample.value = 4;
assertThat(comparisonResult.latencyDelta.best.get(0),equalTo(responseExample));
其中
public List<ResponseExample> best;
爲什麼會出現錯誤equalTo()
?
第一個項目最好的類型爲ResponseExample
Error:(62, 9) java: no suitable method found for assertThat(com.w.routing.automation.dataModel.examples.ResponseExample,com.google.common.base.Predicate<com.w.routing.automation.dataModel.examples.ResponseExample>)
method org.junit.Assert.<T>assertThat(java.lang.String,T,org.hamcrest.Matcher<? super T>) is not applicable
(cannot infer type-variable(s) T
(actual and formal argument lists differ in length))
method org.junit.Assert.<T>assertThat(T,org.hamcrest.Matcher<? super T>) is not applicable
(no instance(s) of type variable(s) T exist so that com.google.common.base.Predicate<T> conforms to org.hamcrest.Matcher<? super T>)