Last active
January 10, 2019 07:49
-
-
Save jieniu/13bab0dcff1b442ea270d2c095849899 to your computer and use it in GitHub Desktop.
java assert exception unitest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static org.junit.jupiter.api.Assertions.assertThrows; | |
@Test | |
public void testUsernameIsNull() { | |
Exception exception = assertThrows(IllegalArgumentException.class, () -> { | |
User user = new User(); | |
user.setName(null); | |
}); | |
Assert.assertEquals("expected message", exception.getMessage()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment