我在瀏覽junit ExpectedExceptions
' javadoc,我無法理解其示例中的startsWith
來自哪裏(在代碼中標記爲HERE)。我檢查了CoreMatcher
utility class但找不到任何靜態startsWith
方法。JUnit Matcher#startsWith的聲明在哪裏?
該方法位於何處?
(我可以明顯地寫自己,但事實並非點)
public static class HasExpectedException {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void throwsNullPointerExceptionWithMessage() {
thrown.expect(NullPointerException.class);
thrown.expectMessage("happened?");
thrown.expectMessage(startsWith("What")); //HERE
throw new NullPointerException("What happened?");
}
}