Skip to content

Warm-up 실습 2주차 - nusuy#5

Open
nusuy wants to merge 11 commits intodevelopfrom
feature/3-nusuy
Open

Warm-up 실습 2주차 - nusuy#5
nusuy wants to merge 11 commits intodevelopfrom
feature/3-nusuy

Conversation

@nusuy
Copy link
Member

@nusuy nusuy commented Sep 20, 2023

@nusuy nusuy self-assigned this Sep 20, 2023
Comment on lines +83 to +89
public ArrayList<NaverRawNewsItemDto> getRawData() {
return rawData;
}

public ArrayList<NewsEntity> getResultData() {
return resultData;
}
Copy link
Member

Choose a reason for hiding this comment

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

테스트를 위해 추가한 함수같은데 비즈니스 로직이 아니라서 없는게 나을 것 같아요.

이 코드로 인해 test와 service 간 의존성이 생기면서 응집도가 낮아진다고 생각합니다.

Copy link
Member Author

Choose a reason for hiding this comment

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

1342de4 3e647fd
두 함수 제거 및 rawData, resultData 필드도 테스트 목적으로 생성한 거라 함께 제거했습니다!

이에 따라 테스트 로직이 전반적으로 수정되었는데, 적재한 데이터를 DB에서 불러와 테스트하는 과정에서 문제가 있어 다음과 같이 변경하였습니다.
뉴스 API 요청하여 데이터를 받아오는 클래스인 NewsDataReader에서 get()메소드가 한 번에 100건을 잘 받아오는지, 받아온 데이터에 쿼리 문자열이 잘 포함되어 있는지 검사합니다.

확인 부탁드립니다!

Copy link
Member

Choose a reason for hiding this comment

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

두 함수 제거 및 rawData, resultData 필드도 테스트 목적으로 생성한 거라 함께 제거했습니다!

좋습니다. 굿굿

뉴스 API 요청하여 데이터를 받아오는 클래스인 NewsDataReader에서 get()메소드가 한 번에 100건을 잘 받아오는지, 받아온 데이터에 쿼리 문자열이 잘 포함되어 있는지 검사합니다.

이거는,, 이게 적재 테스트라서 ok하기 어려울 것 같아요. DB에 멀쩡히 저장되고 읽어지는지를 확인하는 테스트여서 mock이든 실제 db이든 적재 확인은 필수라고 생각합니다.

Copy link
Member Author

Choose a reason for hiding this comment

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

fbf63a9, 69aa439, 8c4301f, 5647f04

테스트 DB 분리하여 적재량 검증하는 과정에서 1,000건이 아닌 1,001건이 저장되었다는 로그와 함께 실패하는 이슈가 있었는데, 해결되어 DB 검증하는 코드로 변경했습니다!
DataUpdateService에서 @PostConstruct로 애플리케이션이 시작하자마자 적재를 실행하도록 설정하는 코드가 테스트 진행 도중 함께 실행되어 발생한 것 같습니다. @PostConstruct 코드 제거하니 테스트 잘 작동합니다!

확인 부탁드려요~!

Copy link
Member

Choose a reason for hiding this comment

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

네 셤 끝나고 확인해드릴게요~

@nusuy nusuy requested a review from hyojeongchoi September 27, 2023 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants