I'm doing some tests for my app and when I send a null it catch NullPointerException. The method still contines but the test present an error. How can avoid it?.
TestService.java
Integer number = null;
ServiceToTest service;
try{
service.methodToTest(number);
}
catch(Exception e){
//Do some stuff
}
ServiceToTest.java
public void methodToTest(Integer number){
if(number != null) //Do some stuff
}
I tried too if(number.equals(null))
but it also have the same exception