Reputation:
For some reason; despite me coding in my validation correctly, JUnit 4 keeps raising a failure even if the exception is thrown:
code:
try {
if (firstname == null) {
throw new IllegalArgumentException("First name cannot be null");
}catch (IllegalArgumentException e) {
e.getMessage();
e.printStackTrace();
}
JUnit:
@Test(expected=IllegalArgumentException.class)
public void testUserInvalidConstructions() {
User user = new User(null);
}
Upvotes: 0
Views: 53
Reputation:
Just realised catching the exception overrides the throw nevermind
Upvotes: 1