如何为if else编码编写测试用例。当将该对象设置为null时,我没有在else块中获得覆盖。 同样也没有在catch区域获得覆盖。
if (Object!= null) {
if (Object.getId() != null) {
responseModel = registrationService.updateVendor(Object);
} else {
responseModel = registrationService.save(Object);
}
} else {
responseModel = new ResponseModel();
responseModel.setCode(ERROR_1002);
responseModel.setMessage(ERROR_MSG1002);
logger.info("Vendor details not found");
}
} catch (NullPointerException e) {
//e.printStackTrace();
responseModel = new ResponseModel();
responseModel.setCode(ERROR_1000);
responseModel.setMessage(ERROR_MSG1000);
logger.error("Exception inside RegistrationController.Registration()" + e);
}