Skip to content

Instantly share code, notes, and snippets.

@BalicantaYao
Created May 8, 2017 08:40
Show Gist options
  • Save BalicantaYao/1c2c7f9c9f778aefc1a19bf4b8bdd1e0 to your computer and use it in GitHub Desktop.
Save BalicantaYao/1c2c7f9c9f778aefc1a19bf4b8bdd1e0 to your computer and use it in GitHub Desktop.
public static class verfiyExceptionTest{
@Rule
public ExpectedException thrown= ExpectedException.none();
@Test
public void throwsExceptionWithMessage() {
// 預期 LoginFailed 會產生以及對應的 Exception message
thrown.expect(LoginFailedException.class);
thrown.expectMessage(startsWith("UserName"));
// 執行測試
checkEmptyUserName(StringUtils.Empty);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment