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); }