4
我一直在試圖斷言,我的設置有收集與hamcrest給定的屬性,使用此solution確切性質,但我有:如何斷言,設置有項目與hamcrest
java.lang.NoSuchMethodError: org.hamcrest.Matcher.describeMismatch(Ljava/lang/Object;Lorg/hamcrest/Description;)V at org.hamcrest.Condition$Matched.matching(Condition.java:52)
進口:
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasProperty;
import static org.junit.Assert.assertThat;
代碼:
assertThat(mySet, contains(hasProperty("id", equalTo("expectedId"))));
你有什麼想法如何斷言它呢?
如果我只是在測試中啓動同一個對象並將其置於我的返回集合中,我就會無法工作,因爲如果您知道我的意思,但我相信它會比較它是否相同的對象,但是,作品 'assertThat(mySet.contains(expectedValue),equalTo(true));' 謝謝:) – Szympek