Open
Conversation
noxknow
reviewed
Apr 17, 2025
Contributor
noxknow
left a comment
There was a problem hiding this comment.
전체적으로 테스트 코드가 잘 구조화되어 있고, 각 기능에 대한 검증을 명확히 하고 있어 인상적입니다! 특히, 유효한 요청과 유효하지 않은 요청에 대해 잘 구분하고 테스트하는 부분이 좋았습니다. 😁
Comment on lines
+165
to
+168
| assertThat(actual).hasSize(1); | ||
| assertThat(actual.getFirst()) | ||
| .usingRecursiveComparison() | ||
| .isEqualTo(expected); |
Contributor
There was a problem hiding this comment.
응답을 usingRecursiveComparison()으로 검증하는 방식은 처음 봤는데 테스트의 신뢰성과 가독성을 동시에 확보할 수 있어 좋았습니다. 👍
다만, JsonPath와 비교했을때 응답 구조 변경에 민감한 특성이 있어서, 향후 API 스펙이 변경될 경우 테스트 유지보수 측면에서 부담이 될 수 있다는 점도 함께 고려되면 좋을 것 같습니다!
Comment on lines
+140
to
+159
| @ParameterizedTest | ||
| @DisplayName("❗ 원고 정보 수정 - 유효하지 않은 요청값") | ||
| @MethodSource("invalidStoryRequests") | ||
| void updateStory_invalidRequest(UpdateStoryRequest invalidRequest) throws Exception { | ||
| // when // then | ||
| mockMvc.perform(put(BASE_URL + "/{storyId}", storyId) | ||
| .header(AUTHORIZATION, testAuthUtils.getAccessToken(member)) | ||
| .contentType(MediaType.APPLICATION_JSON) | ||
| .content(objectMapper.writeValueAsString(invalidRequest)) | ||
| ) | ||
| .andExpect(status().isBadRequest()); | ||
| } | ||
|
|
||
| private static Stream<UpdateStoryRequest> invalidStoryRequests() { | ||
| return Stream.of( | ||
| new UpdateStoryRequest(null, ""), | ||
| new UpdateStoryRequest("", null), | ||
| new UpdateStoryRequest("a".repeat(51), null) | ||
| ); | ||
| } |
Contributor
There was a problem hiding this comment.
@MethodSource를 활용한 테스트로 유효성 검증 케이스들을 명확히 분리하고 반복을 줄인 점이 인상 깊네여! 😊
Comment on lines
+175
to
+185
| @ParameterizedTest | ||
| @DisplayName("❗ Story 이름 변경 - 유효하지 않은 요청") | ||
| @MethodSource("invalidFileNameRequests") | ||
| void updateDndName_invalidRequest(CommonUpdateFileNameRequest invalidRequest) throws Exception { | ||
| // when // then | ||
| mockMvc.perform(patch(BASE_URL + "/{id}/title", story.getId()) | ||
| .header(AUTHORIZATION, testAuthUtils.getAccessToken(member)) | ||
| .contentType(MediaType.APPLICATION_JSON) | ||
| .content(objectMapper.writeValueAsString(invalidRequest))) | ||
| .andExpect(status().isBadRequest()); | ||
| } |
Contributor
There was a problem hiding this comment.
현재는 유효성 검증 실패 시 상태 코드(400)만 검증하고 있는데, 클라이언트가 어떤 필드가 잘못되었는지를 알 수 있도록 응답 본문도 함께 검증하면 좋을 것 같아요..!
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.
📌 연관된 이슈
✌️ Changes
기타