Skip to content

Conversation

@Han-u
Copy link
Contributor

@Han-u Han-u commented Apr 10, 2025

📌 연관된 이슈

#23

✌️ Changes

  • 기존 테스트코드에서 config 설정, project, member 생성하는 코드 따로 뻈습니다 (계속 쓰기 귀찮아,,
  • 테스트 코드가 너무 길어져서 Controller를 Story CRUD - DnD CRUD - AI로 나눠서 작성했습니다
  • 추가로 DnD 순서변경 테스트 케이스 빼서 작성
  • StoryFolder쪽도 동일하게 적용

기타

  • AI 요청보내는 쪽은 아직 안했음
  • 순서변경 테케 중에 trashcan 복구 부분은 순서 조정 안되는 부분 오류가 있어서 << 이번에 작업 합니다.

@Han-u Han-u requested review from given-dragon and noxknow April 10, 2025 13:41
Copy link
Contributor

@noxknow noxknow left a comment

Choose a reason for hiding this comment

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

전체적으로 테스트 코드가 잘 구조화되어 있고, 각 기능에 대한 검증을 명확히 하고 있어 인상적입니다! 특히, 유효한 요청과 유효하지 않은 요청에 대해 잘 구분하고 테스트하는 부분이 좋았습니다. 😁

Comment on lines +165 to +168
assertThat(actual).hasSize(1);
assertThat(actual.getFirst())
.usingRecursiveComparison()
.isEqualTo(expected);
Copy link
Contributor

Choose a reason for hiding this comment

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

응답을 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)
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@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());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

현재는 유효성 검증 실패 시 상태 코드(400)만 검증하고 있는데, 클라이언트가 어떤 필드가 잘못되었는지를 알 수 있도록 응답 본문도 함께 검증하면 좋을 것 같아요..!

Copy link
Contributor

@given-dragon given-dragon left a comment

Choose a reason for hiding this comment

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

고생하셨습니다~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants