Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@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