Skip to content

Conversation

@daehoon12
Copy link
Contributor

@daehoon12 daehoon12 commented Sep 16, 2023

#ISSUE NUM - TITLE

Type

  • New Feature
  • Refactor
  • Bug Fix
  • CI/CD
  • Set Up
  • Small Correction

개요

작업 내용

  • kotest와 mockK를 이용하여 회원 정보 조회, 회원 정보 수정에 대한 단위 테스트 작성
  • kotest와 webClientTest를 이용하여 회원 관련 대한 통합 테스트 poc

코드 리뷰시 참고 사항

@daehoon12 daehoon12 linked an issue Sep 16, 2023 that may be closed by this pull request
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
exclude(group = "org.mockito")
}
testImplementation("org.springframework.restdocs:spring-restdocs-mockmvc")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

spring MVC의 의존성을 자동으로 땡겨오는 원인이었음.

Comment on lines +18 to +25
webTestClient.get()
.uri("/users/me")
.exchange()
.expectStatus().isOk
.expectBody()
.jsonPath("$.data.id").isEqualTo(1)
.jsonPath("$.data.nickname").isEqualTo(principalId)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

webTestClient.get(): HTTP GET 요청을 시작하는 메서드입니다.
.uri("/users/me"): 요청할 URI를 설정합니다. 이 경우에는 "/users/me" 엔드포인트로의 요청을 나타냅니다.
.exchange(): 이전에 구성한 요청을 서버에 전송하고 응답을 받는 메서드입니다.
.expectStatus().isOk: 응답 상태 코드를 검증합니다. isOk는 상태 코드가 200 OK인지 확인합니다.
.expectBody(): 응답 본문(body)에 대한 검증을 시작하는 메서드입니다.
.jsonPath("$.data.id").isEqualTo(principalId): jsonPath는 응답 본문에서 특정 JSON 경로의 값을 가져옵니다. 여기에서는 $.data.id 경로의 값을 가져와 principalId와 같은지 확인합니다.

chatGPT한테 뭐하는 메서드인지 물어봤음.

@Hee-jin506
Copy link
Contributor

testContainer 도입해보시면 좋을 것 같습니다.
테스트 파일들 삭제하신거 다시 원복 부탁드립니다.
감사합니다.

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.

코루틴 환경에서의 테스트 (단위 / 통합)

5 participants