我在浏览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?");
}
}