-
Notifications
You must be signed in to change notification settings - Fork 4
Feat/3 implement Reservation #24
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
Conversation
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## main #24 +/- ##
============================================
- Coverage 50.00% 0.00% -50.00%
============================================
Files 2 4 +2
Lines 8 22 +14
============================================
- Hits 4 0 -4
- Misses 4 22 +18
☔ View full report in Codecov by Sentry. |
해당 commit이 git actions 체크에서 실패했네요 Todo
커밋 이름 변경기존 커밋 이름 변경 후
왜 이런 커밋이 올라갔는지 모르겠지만, 한번 |
개발팀 첫 🥇 기능 구현 PR 축하드립니다 👍 👍 👍 매우 좋습니다 :) |
향후 git issue로 만들 것 (개선사항)
|
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.
check plz
src/main/kotlin/com/group4/ticketingservice/controller/ReservationController.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/com/group4/ticketingservice/domain/Reservation.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/com/group4/ticketingservice/controller/ReservationController.kt
Outdated
Show resolved
Hide resolved
@bohblue2 코드 리뷰 부탁드립니다 (프로젝트 구조 등) |
@yunsuu 테스트 시나리오 작성 및 테스트 코드 작성 부탁드립니다. 참고 |
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.
작은 수정사항이 있습니다. 수정해주세요.
src/main/kotlin/com/group4/ticketingservice/domain/Reservation.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/com/group4/ticketingservice/controller/ReservationController.kt
Outdated
Show resolved
Hide resolved
} | ||
|
||
@PostMapping("/reservation") | ||
fun reservePerformance(@RequestBody reservation: Reservation): Reservation { |
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.
@@ -1 +1,8 @@ | |||
|
|||
#spring.datasource.url=jdbc:mysql://localhost:3306/test |
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.
주석 삭제 부탁드립니다
- 환경변수 주입 방법을 사용하시면 편하게 사용 가능합니다.
fun read(){ | ||
val reservation = Reservation(1) | ||
val savedReservation = reservationRepository.save(reservation) | ||
if(savedReservation != null){ |
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.
테스트 코드에는 조건문이 없어야 합니다!
val savedReservation = reservationRepository.save(reservation)
val foundReservation = reservationRepository.findByUserId(1)
Assertions.assertNotNull(foundReservation)
Asserts.assertEquals(savedReservation.id, foundReservation.id)
으로 수정하는게 좋을 것 같습니다.
또한 코틀린 문법에 따르면 object?.key
도 사용가능할듯합니다
Asserts.assertEquals(savedReservation.id, foundReservation?.id)
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.
1. 레이어별 테스트
해당 테스트는 Repository - Database간의 상호작용을 테스트 하였습니다.
Controller의 테스트가 필요해보입니다. 관련개념글
2. 테스트 환경 격리
해당 테스트 Local 환경에 실제로 구동중인 MySQL에 의존하고 있습니다.
따라서 Git actions를 통해 test 할때는 동일한 환경이 아니기 때문에 실패하게 됩니다. (MySQL이 준비되어 있지 않기 때문에)
격리된 테스트 (Isolated Test) 데이터베이스와 같은 공유 자원을 사용하는 테스트는 실행 순서에 따라 성공, 실패 여부가 결정되는 비결정적인(non-deterministic) 테스트가 될 수 있다. 이런 비결정적 테스트는 실패하면 버그가 원인인지, 비결정적 동작이 원인인지 알기 힘들다. 따라서 테스트는 실행 순서에 상관 없이 독립적으로, 결정적(deterministic)으로 실행되어야한다. 테스트 격리는 공유 자원을 사용하는 여러 테스트끼리 격리하여 서로 영향을 주고 받지 못하게 하는 기법이다. 특히 데이터베이스를 사용하는 객체를 테스트할 때 테스트 격리가 필요하다. - from
해결 방법은 몇가지가 있습니다.
- in-memory Database H2를 사용하여 테스트
- testcontainer 환경에서 (현재 main branch에 준비되어 있습니다) 해당 코드를 테스트 하기
- 해당 Database 테스트는 본질적으로 Unit Test가 아니기에 해당 파일 삭제하기
먼저 1번의 경우 좋은 방법이 아닙니다. 왜냐하면 h2는 mysql 을 mock up(가짜화)하는데 성공해 유닛 테스트를 구현할 수 있게는 해주지만, 본질적으로 mysql이 아니기 때문에 실제와 같은 환경을 제공해주지는 않기 때문입니다.
따라서, 2번이 더 좋은 선택이라고 볼 수 있습니다 - 관련 글
통합 테스트 관련 오류 이슈 #48 |
What is this PR?
Key Changes
Test Checklist