Skip to content
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

테스트 환경 설정 및 리팩터링 #261

Merged
merged 14 commits into from
Nov 24, 2024
Merged

테스트 환경 설정 및 리팩터링 #261

merged 14 commits into from
Nov 24, 2024

Conversation

Lechros
Copy link
Collaborator

@Lechros Lechros commented Nov 19, 2024

변경 내용

개발 환경

  • Dockerfiledevprod 모드 설정 (기본: prod)
  • dev 모드 compose.dev.yml 파일 추가
    • MariaDB 및 Redis 컨테이너 포함

테스트 환경

  • 윈도우에서 임베디드 Redis 실행할 수 있도록 수정
  • 모든 통합 테스트 클래스가 IntegrationTestSupport 상속받도록 수정
  • 모든 @Transactional 어노테이션을 메서드에서 테스트 클래스로 이동
    • 메서드에 추가하면 빠트릴 확률이 더 높고, DBCleaner.execute는 테스트 클래스 단위로 설정되므로 일관성 있도록
  • DBCleanUp -> DBCleaner로 이름 변경 및 하드코딩 리팩터링 (Spring 및 Hibernate 내에서 Cleanup보다 Cleaner 명칭을 더 선호함)
  • application-test.yaml 파일에서 불필요한 속성 제거

기타

  • 파일이 많으니 커밋 단위로 확인해보세요
  • application-dev.yaml 파일은 변경되지 않아 기존 방식대로 실행 가능
  • 트랜잭션 내에서 수행되면 안되는 테스트일 경우 @Transactional 어노테이션이 없는 테스트 클래스에 구현해야 함 (OotdServiceMultiThreadTest 등)
  • 현재 createdAt으로 정렬하는 테스트의 경우 일정 확률로 실패함
  • Repository 테스트에 @DataJpaTest를 사용하도록 변경할 지? @SpringBootTest를 사용해도 테스트 시간 10초로 충분히 빠름

@Lechros Lechros added the enhancement New feature or request label Nov 19, 2024
@Lechros Lechros self-assigned this Nov 19, 2024
@Lechros Lechros requested review from jinhoon227 and kkmin223 and removed request for jinhoon227 November 19, 2024 08:45
Copy link
Collaborator

@kkmin223 kkmin223 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

승인합니다.
createdAt은 트랜잭션이 커밋될 때 동시에 들어가면, 같은 시간으로 들어가서 틀어질 수도 있을 것 같긴 하네요.
JpaTest는 저도 굳이 나눌 필요 없을 것 같다고 생각합니다!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question : 이거 어떻게 사용하나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 IntelliJ 도커 탭으로 실행하고, 제 컴퓨터 환경(윈도우) 기준 스프링은 로컬에 비해 컨테이너가 많이 느려서 로컬로 실행하고 있어요.
커맨드 쓰신다면 아마 아래와 같이 하면 될거예요.

docker compose -f compose.dev.yml up

@Lechros Lechros merged commit 8cdfb3f into develop Nov 24, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants