refactor(test): 테스트 도메인에 싱글톤 컨테이너 도입 #288
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📝 요약(Summary)
기존 테스트 컨테이너(AbstractPostgresContainerTest)는 BeforeAll과 AfterAll 어노테이션을 활용한 'static' 컨테이너로써, 한 테스트 클래스 내에서 여러 메서드가 공유하는 컨테이너였습니다.
이걸 이제 singletone 컨테이너로 변경하여 전체 테스트 클래스가 공유하는 컨테이너로 바꿨습니다.
즉, 매 번 테스트 클래스가 바뀔 때마다 컨테이너를 올리고 내리던 작업을, 전체 테스트 중에 한 번만 올리고, 끝날 때 한 번만 내리는 방식으로 수정했습니다. 더불어 이전 클래스가 쓰던 DB와 그 다음 클래스가 쓰는 DB의 스키마가 차이가 없으므로 스키마 역시 공유되도록 수정했습니다.
이를 통해 DB를 사용하는 테스트들(리포지토리 테스트 클래스들)의 테스트 시간이 감소했고, 전체 테스트 시간이 116초에서 27초 전후로 감소했습니다.
싱글톤 패턴의 가장 큰 단점은 데이터 오염인데, 이를 위해 주의할 점들을 TESTING.md에 정리해놨습니다.
📸스크린샷 (선택)
💬 공유사항
✅ PR Checklist
PR이 다음 요구 사항을 충족하는지 확인하세요.