java - NullPointerException in JUnit Test -


i'm doing tests app , when send null catch nullpointerexception. method still contines test present error. how can avoid it?.

testservice.java

integer number = null;  servicetotest service;  try{     service.methodtotest(number); } catch(exception e){ //do stuff } 

servicetotest.java

public void methodtotest(integer number){    if(number != null) //do stuff } 

i tried if(number.equals(null)) have same exception

use

@test(expected=nullpointerexception.class) 

instead of

@test 

and error-message go away.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -