Skip to content

Instantly share code, notes, and snippets.

@Rene-Frerichs
Created November 26, 2015 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rene-Frerichs/081357e294fc68aa401f to your computer and use it in GitHub Desktop.
Save Rene-Frerichs/081357e294fc68aa401f to your computer and use it in GitHub Desktop.
Classic JUnit exception testing
@Test
public void tryCatch() {
try {
methodThrowsIllegalArgument();
fail("Expected IllegalArgumentException!");
} catch (IllegalArgumentException exception) {
assertThat(exception.getMessage(), is("Invalid Argument"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment