jeudi 3 septembre 2015

How can One can write a Junit Test Cases of If-else condition in a Method

I am doing unit test of my controller and and got stuck when I was writing the unit case for these line of codes

List<User> users = null;
if (userId != null && userId.length() > 0) {
    List<String> uIdLst= Arrays.asList(userId.split(","));
    log.info("" + uIdLst);
    users = userService.getUsers(uIdLst);
} else {
    users = userService.getUsers(dfer, cmk);
}

Can anyone could suggest me the way to write a unit case for these line of codes.

Aucun commentaire:

Enregistrer un commentaire