-
Notifications
You must be signed in to change notification settings - Fork 2
test containers 전역테스트 대상 제외, jacoco 개발환경용 설정 수정 #112
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
Conversation
init.sql은 테이블 정의, data.sql은 데이터 삽입, delete.sql은 테이블 초기화를 담당합니다.
testcontainers를 사용하여, MariaDB 기반의 TestExtension을 정의했습니다. MariaDBAdapterTest는 이 Extension을 포함하여, MariaDB 통합테스트에 필요한 공통 코드들을 포함합니다.
MariaDBAdapterTest 클래스를 활용하여 Repository에 대한 샘플 테스트코드를 추가했습니다. 실제로는 save, find, custom query에 대해 테스트가 이루어져야 합니다.
누락되었던 testcontainers library들을 추가했습니다
userId와 name을 Annotation에 전달하면 해당 userId와 name을 가진 Authentication 객체가 자동으로 mockmvc 요청에 포함됩니다.
performGet, performPost 메서드는 mockmvc 요청시 기본적인 설정만 포함한 메서드라 선택적으로 사용하시면 됩니다. convertAs 메서드를 사용하면, mockMVC의 응답으로 반환된 jsonString을 특정 ResponseDto 객체로 변환 가능합니다. 이 때, 변환 대상인 ResponseDto 객체의 class를 인자로 전달해주셔야 합니다.
ControllerTest base 테스트를 사용하는 AssetController의 샘플 테스트코드를 추가했습니다. WebMvcTest Annotation으로 테스트 대상 Controller 클래스를 명시해주셔야 하며, 서비스는 MockitoBean Annotation으로 mocking하여 기대하는 응답을 반환토록 해야 합니다.
WithCustomMockUser 사용을 위해 필요한 dependency입니다.
stomp client 테스트에 사용할 수 있는 Base Test를 추가했습니다.
it profile이더라도 h2-mem일 경우에 동작하도록 변경합니다.
구독을 했을 때, 정상적으로 stomp 메시지를 수신할 수 있는지 테스트합니다.
시간 불일치 이슈가 발생할 수 있어 해당 Config를 포함시켰습니다.
Sql Annotation의 테스트 이후 truncate 작업이 다른 트랜잭션과 충돌하여 병목이 발생했었습니다. 테이블 초기화 작업을 테스트 후가 아닌 테스트 전에 실행되도록 수정했습니다.
testcontainers를 사용하는 db 통합 테스트 특성상 테스트가 매우 무겁기 때문에, 기본적인 JUnit 테스트 대상에서 제외하도록 Diabled annotation을 추가했습니다.
주문 생성 봇의 로직이 포함되지 않은 환경에서 수행되도록 profile 설정을 변경했습니다.
기존 Disabled Annotation만으로는 sub클래스 테스트 제외까지 시키지 못했던점을 고려해 Tag 기반으로 전역 테스트 제외 설정을 했습니다.
개발 환경에서 자신의 패키지에 대해서만 테스트 커버리지를 생성할 수 있도록 주석처리된 설정을 반영했습니다
jacoco 설정 반영을 위해 실패하던 테스트를 임시로 비활성화해두었습니다. 다른 branch에서 수정예정입니다.
|
caniro
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
테스트 관련 공통 설정 변경 고생하셨습니다.
| excludeTags 'testcontainers' | ||
| } | ||
| dependsOn test | ||
| finalizedBy jacocoTestReport |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
depensOn 대신 finalizedBy 사용 시, 테스트가 실패해도 SonarQube에서 항상 커버리지 리포트를 볼 수 있다는 장점이 있네요

0 New Issues
0 Fixed Issues
0 Accepted Issues
No data about coverage (57.00% Estimated after merge)
✨ 작업내용
🐞 이슈사항