This question already has an answer here:
- Concatenating null strings in Java 5 answers
I am trying to pass a null to a method hoping it would throw IllegalArgumentException error but instead method is taking that null as String. What am I doing wrong?
Below is the Test Method:
@Test
public void verifyExceptionForNameIsNull(){
Greeting myGreeting = new GreetingImpl();
myGreeting.greeting(null);
Out put of the method is "Hello null".
Below is the class where method is defined:
public class GreetingImpl implements Greeting {
@Override
public String greeting(String name) {
return "Hello "+name;
}
}
Aucun commentaire:
Enregistrer un commentaire