lundi 16 février 2015

Java requireNonNull always returns true when Unit Testing

Im trying to implement requireNonNull check on my object when Unit testing using JUnit, Im expecting an Exception to be throw but never is...



public TheClass(final String name) {
requireNonNull(!StringUtils.isBlank(name), "name cannot be null/empty");

this.name = name;
}


//Test



@Test(expected = IllegalArgumentException.class)
public void testInstantiateWithNullName() {
new TheClass(null);
}


Any Ideas....


Iv also ran the test with 'expected = NullPointerException.class'


Aucun commentaire:

Enregistrer un commentaire