這裏,https://github.com/junit-team/junit/wiki/Assertions,看:新語法或拼寫錯誤?
public void testAssertThatHamcrestCoreMatchers() {
assertThat("good", allOf(equalTo("good"), startsWith("good")));
assertThat("good", not(allOf(equalTo("bad"), equalTo("good"))));
assertThat("good", anyOf(equalTo("bad"), equalTo("good")));
assertThat(7, not(CombinableMatcher.<Integer> either(equalTo(3)).or(equalTo(4))));
assertThat(new Object(), not(sameInstance(new Object())));
}
在5日線,CombinableMatcher.<Integer>
是有效的?我用java6試用它,失敗了。 它是一種新的語法或簡單的錯字?
*「我嘗試它的Java6,失敗」 * - 你能更具體說明究竟是什麼失敗? –
合法的語法,而不是全新的。它指定了「任一」方法的類型參數。 –