Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✅ Refactor: UserServiceTest Mock으로 리팩토링 (#26) #27

Merged
merged 4 commits into from
Oct 15, 2023

Conversation

win-luck
Copy link
Contributor

@win-luck win-luck commented Oct 14, 2023

  • User 객체 image 속성 주요 메서드에 누락된 버그 수정 (FoodServiceTest에 수정사항 반영)
  • UserServiceTest Mock 객체 도입
  • UserService 검색결과에서 자신 배제하는 보완 로직 추가
  • 원활한 테스트코드를 위해 User에 setId() 추가

@win-luck win-luck added the refactor 리팩토링 label Oct 14, 2023
@win-luck win-luck requested a review from synoti21 October 14, 2023 16:18
@win-luck win-luck self-assigned this Oct 14, 2023
@win-luck win-luck linked an issue Oct 14, 2023 that may be closed by this pull request
@win-luck win-luck changed the title Feature/26 refactor userservicetest ✅ Refactor: UserServiceTest Mock으로 리팩토링 (#26) Oct 14, 2023
@@ -53,7 +53,7 @@ public void setUp() {
void testSaveAndGetFood() { // 음식 정보 저장 및 해당 날짜 음식 리스트 불러오기
// given
BaseNutrition testBaseNutrition = BaseNutrition.createNutrition(1,1,1,1);
Long userId = userService.saveUser(CreateUserDto.of("testUser", "testPassword", 1,180, 80,18));
Long userId = userService.saveUser(CreateUserDto.of("testUser", "testImage","testPassword", 1,180, 80,18));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FoodService 테스트 쪽도 수정해주셔서 감사합니다~


// when
ResponseUserDto responseUserDto = userService.getUserInfo(userId);
given(userRepository.existsByName("test")).willReturn(false); // 유저가 존재하지 않음
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stubbing을 사용하셨군요! 참고해서 FoodServiceTest도 mocking으로 리팩토링 하겠습니다!

@synoti21 synoti21 merged commit f3c862c into master Oct 15, 2023
1 check passed
@synoti21 synoti21 deleted the feature/26-refactor-userservicetest branch October 15, 2023 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor 리팩토링
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✅ Refactor: UserServiceTest Mock으로 리팩토링 (#26)
2 participants