【发布时间】:2012-10-20 09:25:23
【问题描述】:
我正在浏览junit ExpectedExceptions' javadoc,但我不明白他们示例中的startsWith 来自哪里(在代码中标记为此处)。我检查了CoreMatcher utility class,但找不到任何静态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?");
}
}
【问题讨论】: