@Override
public User editDescription(User user, String description) throws UserNotFoundException {
user.setAboutMe(description);
User returnedUser = userRepository.save(user);
if (returnedUser == null) {
throw new UserNotFoundException();
}
return returnedUser;
}
我有这个服务实现,测试用例是:
@Test
public void shouldEditDescriptionOfTheUser() throws UserNotFoundException{
databuilderService.createAll();
User user = userService.findByEmail("abc@gmail.com");
user.setAboutMe("It's a description about the user");
userService.save(user);
String aboutMe = user.getAboutMe();
LOGGER.info(aboutMe);
Assert.assertNotNull(aboutMe);
}
这个测试用例是否涵盖所有分支?我是否应该编写另一个测试用例来检查作为服务分支的用户对象(空检查)的值?