-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Refactor/#329] 테스트 코드 보강 및 개선 #330
Conversation
104f00c
to
d069f02
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
헐
this.webTestClient.post() | ||
.uri(uri) | ||
.accept(MediaType.APPLICATION_JSON) | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.bodyValue(body) | ||
.exchange().expectStatus().is2xxSuccessful() | ||
.expectBody().consumeWith( | ||
WebTestClientRestDocumentation.document( | ||
mockMvc.perform( | ||
post(uri) | ||
.content(body) | ||
.contentType(MediaType.APPLICATION_JSON) | ||
) | ||
.andExpect(status().isOk) | ||
.andDo( | ||
document( | ||
api.toIdentifier(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 벌써?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저에겐 코파일럿이 있으니까요.!ㅎㅎㅎ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코파일럿이 이런것도 바꿔줘요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해주는건 아니고 복붙하기 쉽게 도와준다..?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙆🏼♂️🙆🏼♂️
64c136e
to
8d4cf9b
Compare
given("로그인 여부와 상관없이 아티클 조회 요청이 온 상황에서") { | ||
val articleId = 1L | ||
val memberId = 1L | ||
val useCaseIn = ReadArticleUseCaseIn(articleId, memberId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given을 기준으로 useCaseIn을 선언하였습니다.
val memberId = 1L | ||
val useCaseIn = ReadArticleUseCaseIn(articleId, memberId) | ||
|
||
`when`("요청한 아티클과 작가가 존재할 경우") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
따로 UC에 분기가 없는 경우 존재를 확인합니다.
then("아티클과 연관된 정보를 조회한다") { | ||
val useCaseOut = useCase.execute(useCaseIn) | ||
useCaseOut.id shouldBe articleId | ||
useCaseOut.writer.id shouldBe writerId | ||
useCaseOut.writer.name shouldBe writerName | ||
useCaseOut.writer.url shouldBe mainImageURL | ||
useCaseOut.writer.imageUrl shouldBe writerProfileImageURL | ||
useCaseOut.mainImageUrl shouldBe mainImageURL | ||
useCaseOut.title shouldBe title | ||
useCaseOut.content shouldBe content | ||
useCaseOut.problemIds shouldBe problemIds | ||
useCaseOut.category shouldBe CategoryType.ECONOMY.displayName | ||
useCaseOut.views shouldBe views | ||
useCaseOut.workbooks shouldBe emptyList() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then에서 uscaseOut도 검증합니다.
verify(exactly = 1) { articleDao.selectArticleRecord(any()) } | ||
verify(exactly = 1) { readArticleWriterRecordService.execute(any()) } | ||
verify(exactly = 0) { browseArticleProblemsService.execute(any()) } | ||
verify(exactly = 0) { articleViewCountHandler.browseArticleViewCount(any()) } | ||
verify(exactly = 0) { articleViewHisAsyncHandler.addArticleViewHis(any(), any(), any()) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given 단위로 동일한 동작 수행을 검증합니다.
@@ -27,69 +29,99 @@ class SaveMemberUseCaseTest : BehaviorSpec({ | |||
} | |||
|
|||
given("회원가입/로그인 요청이 온 상황에서") { | |||
val email = "[email protected]" | |||
val useCaseIn = SaveMemberUseCaseIn(email = email) | |||
|
|||
`when`("요청의 이메일이 가입 이력이 없는 경우") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
분기가 있는 경우 분기를 기준으로 when을 설정합니다.
8d4cf9b
to
2937be3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
테스트 코드 확인했습니다~
🎫 연관 이슈
resolved: #329
💁♂️ PR 내용
🙏 작업
🙈 PR 참고 사항
📸 스크린샷
🤖 테스트 체크리스트