Skip to content

Instantly share code, notes, and snippets.

@jbleduigou
Created January 22, 2020 20:14
Show Gist options
  • Save jbleduigou/5f22fdc21671fc35f3ae5ca3122ea1a4 to your computer and use it in GitHub Desktop.
Save jbleduigou/5f22fdc21671fc35f3ae5ca3122ea1a4 to your computer and use it in GitHub Desktop.
how to assert exception with Junit 5
Throwable exception = assertThrows(BusinessLogicException.class,
() -> userService.getUserDetails(1337));
assertThat(exception.getMessage(), is("Could not get user details!"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment