Skip to content

[Test] Category API 테스트#227

Merged
willjsw merged 12 commits into
developfrom
test/#217-category-api
Oct 29, 2025
Merged

[Test] Category API 테스트#227
willjsw merged 12 commits into
developfrom
test/#217-category-api

Conversation

@haeda0225

@haeda0225 haeda0225 commented Oct 27, 2025

Copy link
Copy Markdown
Contributor

🛠️ Issue Number

closes #217

📌 작업 내용 및 특이사항

필수 테스트 (Controller 6개 엔드포인트)

  • GET /categories – 루트 카테고리 조회
  • GET /categories – 특정 부모의 하위 카테고리 조회
  • GET /categories/{id} – 특정 카테고리 조회
  • GET /categories/tree – 카테고리 트리 조회
  • POST /categories – 카테고리 생성
  • PATCH /categories/{id} – 카테고리 수정
  • DELETE /categories/{id} – 카테고리 삭제

📚 참고사항

예외/추가 테스트

  • POST /categories – 이름 없이 생성 시 400 에러
  • POST /categories – 이름 null 시 400 에러
  • POST /categories – 루트 카테고리 생성

@haeda0225 haeda0225 added this to the Sprint 2 milestone Oct 27, 2025
@haeda0225 haeda0225 added the ✅ test 테스트를 작성, 또는 수정합니다. label Oct 27, 2025
@haeda0225 haeda0225 self-assigned this Oct 27, 2025

@willjsw willjsw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

현재 구성하신 테스트의 Document 응답 필드 등, 실제 코드와 제대로 매칭되지 않는 부분이 많은 듯 합니다.
CI 결과를 보면, 카테고리 관련 7개 테스트가 실패한 것 같네요

PR 리뷰를 요청하시기 전 최소 한번은 로컬 환경에서 실행시켜보시고, 문제가 없는 지 검토해주시기를 부탁드립니다!

Image

Comment on lines +71 to +73
fieldWithPath("[].categoryId").description("카테고리 ID"),
fieldWithPath("[].name").description("카테고리명"),
fieldWithPath("[].depth").description("카테고리 깊이"))));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

P1: jsonPath() 메소드 사용해주시고, 응답 필드는 저희 사용하고 있는 공통 응답 필드를 참고해서 작성해주시기 바랍니다! $.success, $.data.categoryId 와 같이 경로가 구성될 것 같습니다.


// When & Then
mockMvc.perform(get("/categories").with(csrf()))
.andExpect(status().isOk())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

P2: 응답 상태만 확인하는 것으로는 부족할 것 같습니다. andExpect 통해 모든 응답필드가 제대로 반환되고 있는지까지 검증해주세요!

@DisplayName("카테고리 생성 시 이름이 null이면 400 에러")
void createCategory_WithNullName_Returns400() throws Exception {
// Given
String requestJson = "{\"name\": null, \"parentId\": null}";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

P2: 요청을 순수 문자열로 구성하면 이후 코드 변경 시 유지 보수가 어려워집니다! 요청에 필요한 Request 객체를 직접 생성해서 테스트 진행해주세요!

@willjsw willjsw modified the milestones: Sprint 2, Sprint 3 Oct 27, 2025

@isak-kang isak-kang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

고생하셨습니다!

@willjsw willjsw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@willjsw
willjsw merged commit 2e879ae into develop Oct 29, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✅ test 테스트를 작성, 또는 수정합니다.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Test] Category API Test

3 participants