[Day 3-4] Product 도메인 개발#6
Open
JeongUijeong wants to merge 20 commits intoboocam-project:JeongUijeongfrom
Open
[Day 3-4] Product 도메인 개발#6JeongUijeong wants to merge 20 commits intoboocam-project:JeongUijeongfrom
JeongUijeong wants to merge 20 commits intoboocam-project:JeongUijeongfrom
Conversation
- UserTest 클래스를 삭제하고 UserServiceTest를 생성하여 단위테스트를 진행 - mock 객체를 통한 독립적인 테스트 코드 구현 - 예외처리 확인 테스트 코드 추가 - inner 클래스를 활용한 테스트 세분화
- restController -> restcontroller - UserControllerTest -> UserRestControllerTest
- 상품 Dto 생성 - 상품 서비스 생성 - 상품 판매 상태 변경 시 발생할 수 있는 익셉션 생성 - 상품 jpa 레포지토리 생성
- 새상품 등록 및 상품 재고 추가 요청 도메인 생성 - 새상품 등록 및 상품 재고 추가 기능 구현
- 관리자가 아닐 경우 발생시킬 익셉션 생성 - 익셉션 발생 시 적절한 응답을 보내도록 컨트롤러 어드바이스 생성 - 상품 등록 및 재고 추가 컨트롤러(REST) 구현
|
TEST를 상세히 구현해주셨네요. 꼼꼼함이 느껴지는 코드입니다 😁 |
KwonJuHwan
approved these changes
Aug 7, 2023
| } | ||
| } | ||
|
|
||
| @PostMapping("/stock-up") |
| }); | ||
| assertEquals("일치하는 상품이 없습니다.", exception.getMessage()); | ||
| verify(productRepository, times(1)).findById(any(Long.class)); | ||
| } |
There was a problem hiding this comment.
사용자가 상품을 구매할 때, 일치하는 상품이 없는 경우에 대한 테스트는 어떤 시나리오가 있을까요?
사용자가 상품을 구매할 때엔, 상품 리스트 페이지나 상품 상세 페이지에서 상품 구매를 진행한다고 하면, 상품이 있다는 전제 하에 진행되므로 필요하지 않는 테스트라고 생각되어 리뷰를 남깁니다. 저의 생각으로는 일치하는 상품이 없는 경우는 앞선 상품 재고 추가나 상품 이름으로 검색과 같은 케이스에서 필요한 TEST라고 생각해요
Author
There was a problem hiding this comment.
여러 상황을 테스트 해보려다 보니, 불필요한 테스트를 추가해버렸네요! 짚어주셔서 감사합니다~😅
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Product 도메인 개발 PR 올리니, 확인해주시고 피드백 부탁드립니다! 😁
<상품 등록 및 재고 추가 기능>
<관리자 권한 체크>
<판매 시 재고 수정>
<익셉션>