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

test: Database cleaner 리팩토링 #389

Merged
merged 9 commits into from
Jun 16, 2024
Merged

Conversation

char-yb
Copy link
Member

@char-yb char-yb commented Apr 27, 2024

🌱 관련 이슈

📌 작업 내용 및 특이사항

  • JUnit의 Extension 활용
  • Auto Detection

📝 참고사항

📚 기타

@char-yb char-yb added 🥉 P3 급하지 않은 이슈 ✅ test 테스트 작업 labels Apr 27, 2024
@char-yb char-yb self-assigned this Apr 27, 2024
@char-yb char-yb linked an issue Apr 27, 2024 that may be closed by this pull request
@char-yb char-yb marked this pull request as ready for review April 29, 2024 00:48
@char-yb char-yb requested a review from kdomo as a code owner April 29, 2024 00:48
public void beforeEach(ExtensionContext extensionContext) {
var applicationContext = SpringExtension.getApplicationContext(extensionContext);

// validateTransactionalAnnotationExists(extensionContext);
Copy link
Member

Choose a reason for hiding this comment

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

여기는 사용 안하는 건가요?

Copy link
Member Author

@char-yb char-yb Apr 29, 2024

Choose a reason for hiding this comment

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

@uwoobeat 사용하려 했으나 MissionRepository 테스트 내에서는 @Transaction이 걸려있지 않고, Repository 테스트 시 Assertions이 걸려서 지금 알아보고 있는 중임다

아마 @DataJpaTest 내에 Transactional 어노테이션이 걸려있어서 그런가 합리적 의심중...

Copy link
Member

Choose a reason for hiding this comment

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

음 굳이 JUnit Extension으로 해결하지 않아도 괜찮지 않을까요?

GDSC-Hongik/gdsc-server#268

요건 제가 딴 플젝에서 세팅한 통합 테스트 템플릿인데요, 여기서는 각각의 통합 테스트 클래스가 IntegrationTest 를 상속받도록 하고, 템플릿 내에서 @BeforeEach 에서 클리너를 명시적으로 호출하는 방식으로 해결했어요.

개인적으로는 auto detection 방식이 과도하게 로직을 감추고 있어서 내부 동작을 이해하기 어렵게 만드는 것 같다는 생각이 드네요

Copy link

@char-yb char-yb changed the title test: Database cleaner JUnit extension으로 변환 test: Database cleaner 리팩토링 May 1, 2024
Copy link
Member

@uwoobeat uwoobeat left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Member

@kdomo kdomo left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@char-yb char-yb merged commit 4ad8b81 into develop Jun 16, 2024
2 checks passed
@github-actions github-actions bot added the merged 머지된 PR label Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged 머지된 PR 🥉 P3 급하지 않은 이슈 ✅ test 테스트 작업
Projects
Status: 완료
Development

Successfully merging this pull request may close these issues.

✅ Database Cleaner 리팩토링
3 participants