-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
배경
현재 백엔드에 contextLoads() 외 테스트 코드가 전무하며, test profile·fixture·mock 등 테스트 인프라도 없는 상태다.
서비스 ~40개·도메인 13개 패키지 규모로 성장했고, FULLTEXT native query 등 MySQL 전용 문법이 존재하여
Testcontainers MySQL 기반의 테스트 체계가 필요함.
설명
- 테스트 인프라 기반 구축 (Testcontainers MySQL, test profile, fixture 팩토리, Security/Tenant 지원 클래스)
- 도메인 단위 테스트 작성 (Entity 상태 전이, 비즈니스 규칙 검증)
- 서비스 단위 테스트 작성 (Mockito 기반 핵심 비즈니스 로직 검증)
- 컨트롤러 슬라이스 테스트 작성 (선택적,
@WebMvcTest) - Repository 슬라이스 테스트 작성 (선택적, 커스텀 쿼리 대상)
완료 조건
1. 테스트 인프라
-
build.gradle에 Testcontainers 의존성 추가됨 (spring-boot-testcontainers,testcontainers:mysql,testcontainers:junit-jupiter) -
application-test.yml생성됨 (Flyway 스키마 생성, JWT 테스트 키 포함) -
TestcontainersConfig생성됨 (@ServiceConnection기반 MySQL 8.0 컨테이너) -
ServiceTest메타 어노테이션 생성됨 -
TenantTestSupport에서TenantContextHolder세팅/정리 지원함 -
SecurityTestSupport에서@CurrentUserId주입 테스트 지원함 - 주요 도메인별 Fixture 팩토리 생성됨 (Student, Dojang, User, Invoice 등)
-
./gradlew test실행 시 전체 테스트 통과함
2. 도메인 단위 테스트 (P0)
-
InvoiceEntity 생성·상태 전이·비즈니스 규칙 테스트 작성됨 -
PaymentEntity 생성·상태 전이 테스트 작성됨 -
RefundEntity 생성·상태 전이 테스트 작성됨 -
AttendanceEntity 상태 전이 테스트 작성됨
3. 서비스 단위 테스트 (P0)
-
InvoiceService핵심 메서드 Mockito 기반 테스트 작성됨 -
PaymentService핵심 메서드 테스트 작성됨 -
PgPaymentService결제 승인/보상 취소 테스트 작성됨 -
RefundService환불 처리 테스트 작성됨 -
AutoInvoiceService자동 청구 로직 테스트 작성됨 - 외부 서비스(
TossPaymentClient,SmsService) Mock으로 대체됨
4. 테스트 품질
- 모든 테스트가 Given-When-Then 패턴을 따름
-
@DisplayName으로 한글 설명 작성됨 - 테스트 간 독립성 보장됨 (순서 무관하게 통과)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels