Skip to content

[TEST] 결제 관련 기능 테스트 코드 작성#238

Merged
EndlessMilkyway merged 3 commits into
developfrom
test/224-payment-logic-test
Aug 7, 2025
Merged

[TEST] 결제 관련 기능 테스트 코드 작성#238
EndlessMilkyway merged 3 commits into
developfrom
test/224-payment-logic-test

Conversation

@EndlessMilkyway

Copy link
Copy Markdown
Contributor

관련 Issue (필수)

주요 변경 사항 (필수)

테스트 설정 계층

@BeforeEach 설정
├── Member 생성
│   ├── MemberFixture.createStandardMember()
│   └── memberRepository.save()
├── Train 생성
│   └── trainTestHelper.createKTX()
├── TrainSchedule 생성
│   └── trainScheduleTestHelper.createSchedule()
└── Reservation 생성
    └── reservationTestHelper.createReservation()

🔄 1. 결제 처리 (Payment Processing)

✅ 성공 케이스

├── processPaymentViaCard_success() ["카드 결제가 성공한다"]
│   ├── 카드 결제 요청
│   ├── 응답 데이터 검증
│   ├── Payment 엔티티 상태 확인
│   └── Reservation 상태 변경 확인
└── processPaymentViaBankAccount_success() ["계좌이체 결제가 성공한다"]
    ├── 계좌이체 결제 요청
    ├── 응답 데이터 검증
    ├── Payment 엔티티 상태 확인
    └── Reservation 상태 변경 확인

❌ 실패 케이스

├── processPayment_fail_whenAmountMismatch() ["금액이 일치하지 않으면 결제가 실패한다"]
│   ├── 잘못된 금액으로 결제 시도
│   └── PaymentError.PAYMENT_AMOUNT_MISMATCH 예외 검증
├── processPayment_fail_whenNotOwner() ["다른 사용자의 예약으로는 결제할 수 없다"]
│   ├── 다른 사용자로 결제 시도
│   └── PaymentError.RESERVATION_ACCESS_DENIED 예외 검증
└── processPayment_fail_whenAlreadyPaid() ["이미 결제된 예약은 중복 결제할 수 없다"]
    ├── 첫 번째 결제 완료
    ├── 두 번째 결제 시도
    └── PaymentError.RESERVATION_NOT_PAYABLE 예외 검증

🚫 2. 결제 취소 (Payment Cancellation)

✅ 성공 케이스

└── cancelPayment_success() ["결제 취소가 성공한다"]
    ├── 사전 결제 진행
    ├── 결제 취소 요청
    ├── 취소 응답 데이터 검증
    ├── Payment 상태 → REFUNDED 확인
    └── Reservation 상태 → REFUNDED 확인

❌ 실패 케이스

└── cancelPayment_fail_whenNotOwner() ["다른 사용자의 결제는 취소할 수 없다"]
    ├── 사용자 A가 결제 진행
    ├── 사용자 B가 취소 시도
    └── PaymentError.PAYMENT_ACCESS_DENIED 예외 검증

📋 3. 결제 내역 조회 (Payment History)

✅ 성공 케이스

└── getPaymentHistory_success() ["결제 내역 조회가 성공한다"]
    ├── 카드 결제 진행 (StationFare 중복 생성 문제 회피)
    ├── 결제 내역 조회
    ├── 결과 개수 검증 (1개)
    ├── 결제 방법 확인 (CARD)
    ├── 결제 상태 확인 (PAID)
    ├── 결제 금액 확인
    └── 결제 키/예약 코드 확인

❌ 실패 케이스

└── getPaymentHistory_fail_whenMemberNotFound() ["존재하지 않는 회원의 결제 내역 조회 시 예외가 발생한다"]
    ├── 존재하지 않는 회원 번호로 조회
    └── "사용자를 찾을 수 없습니다." 예외 검증

리뷰어 참고 사항

localhost_63342_railo_build_reports_jacoco_test_html_com sudo railo payment application_PaymentService html

추가 정보

없음

PR 작성 체크리스트 (필수)

  • 제목이 Issue와 동일함을 확인했습니다.
  • 리뷰어를 지정했습니다.
  • 프로젝트를 연결했습니다.

@Friox Friox 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.

'다른 사용자의 예약으로는 결제할 수 없다' 등 특수한 케이스도 고려하여 잘 작성하신 것 같습니다!
저도 Fixture를 별도로 생성하여 작성하면 어땠을까하는 생각이 드네요.
주석이 적절하게 달려있어서 보기 편했습니다. 고생하셨습니다! 👍👍

@Yunsung-Jo Yunsung-Jo 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.

고생하셨습니다! 👍

@Jimin730 Jimin730 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.

PR에 테스트 로직 별로 흐름을 꼼꼼하게 작성해주셔서 읽기 수월 했던 것 같습니다!
다양한 예외 케이스들 또한 고려하여 테스트 코드 작성해 주신 것까지 모두 확인했습니다
고생하셨습니다 👍 👍

@chanwonlee chanwonlee 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.

예외 상황까지 꼼꼼하게 테스트해 주신 것 같아 좋네요! PaymentFixture를 활용해서 테스트 데이터를 생성하니 코드가 깔끔한 것 같습니다. 수고하셨습니다!

Comment thread src/test/java/com/sudo/railo/payment/application/PaymentServiceTest.java Outdated

@Ogu1208 Ogu1208 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.

중간에 합류하셔서 결제 기능을 처음부터 구현하시느라 고생하셨을텐데 테스트코드까지 시간내에 작성해주셔서 멋집니다 👍👍

이후에 여유가 되실 때 아래 케이스들도 테스트해보시면 좋을 것 같습니다

  • 존재하지 않는 예약 결제 실패
  • 이미 취소된 결제는 재취소 불가능
  • 동일한 예약에 대한 동시 결제 요청 시 하나만 성공 (동시성 테스트)

정말 너무너무 고생하셨습니다 👍👍

@EndlessMilkyway EndlessMilkyway force-pushed the test/224-payment-logic-test branch from c924a2d to e70d7a3 Compare August 7, 2025 02:38
@EndlessMilkyway EndlessMilkyway merged commit e002f64 into develop Aug 7, 2025
3 checks passed
@EndlessMilkyway EndlessMilkyway deleted the test/224-payment-logic-test branch August 7, 2025 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[TEST] 결제 관련 기능 테스트 코드 작성

6 participants