Skip to content

Instantly share code, notes, and snippets.

@bufferings
Last active March 23, 2021 14:40
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 bufferings/8e4eebcf52091eadf8fa35dcde3313d5 to your computer and use it in GitHub Desktop.
Save bufferings/8e4eebcf52091eadf8fa35dcde3313d5 to your computer and use it in GitHub Desktop.
@Test
void testHelpfulNullPointerExceptions() {
NullPointerException npe = assertThrows(NullPointerException.class, () -> {
Object o = null;
o.toString();
});
assertEquals("Cannot invoke \"Object.toString()\" because \"o\" is null", npe.getMessage());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment