我正在浏览junitExpectedExceptions
的 javadoc,但我无法理解startsWith
他们示例中的 来自哪里(在代码中标记为 HERE)。我检查了CoreMatcher
实用程序类,但找不到任何静态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?");
}
}