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

[CT-65] ChartGameViewModel Unit Test 작성 #68

Open
wants to merge 24 commits into
base: develop
Choose a base branch
from

Conversation

nosorae
Copy link
Collaborator

@nosorae nosorae commented Jul 9, 2024

Overview

  • ChartGameViewModel 에 대한 테스트를 작성했습니다.
  • 커버리지는 라인 수 기반으로는 97% 분기 수 기반으로는 80%입니다.
  • 자세한 내용은 멘토링 시간에 말씀드려야할 것 같습니다.

어려웠던 점

  • 운영 코드가 아니라 (당연히 버그가 없겠다 싶은) Fake 로 만든 Dao 에서 버그가 발생해서 한동안 삽질을 했네요..
    • 예를 들어 StateFlow 에 equals 를 값이아닌 참조로 비교하는 객체를 쓸 때 내부 상태 바꿔도 업데이트되지 않는 당연한(하지만 또 당한) 이슈..가 있습니다. 하하..
  • 한 테스트에 하나의 assertion만 넣는다는 규칙을 지키려다보니 중복되는 코드가 너무 많이 생김
    • 예를 들어 Given은 같은데 screenEvent와 screenState 를 모두 검증해야할 때입니다.
      • 현재 상태는 한 테스트에 모두 검증한 경우도 있고 아닌 경우도 있습니다.

테스트 코드 작성하다가 수정한 운영코드들

  • 차트 변경할 때 차트게임의 차트가 업데이트되지 않는 버그 수정
  • 상수 값을 잘못 준 것 정상화 (Hour 에 "day" 를 주고 있었네요..)
  • 기타 테스트하다가 발견한 불필요 한 필드 제거 등..

nosorae added 24 commits July 2, 2024 19:06
…일 때 원소가 변경되어도 참조값으로 비교되어 업데이트되지 않는 이슈 해결
…keChartTrainerLogger 추가, dao 에 강제로 throw 던지는 flag 역할하는 boolean 변수 추가
@nosorae nosorae added the test test code label Jul 9, 2024
@nosorae nosorae added this to the 프로젝트 고도화 milestone Jul 9, 2024
@nosorae nosorae requested a review from f-lab-nathan July 9, 2024 09:30
@nosorae nosorae self-assigned this Jul 9, 2024
Copy link

sonarqubecloud bot commented Jul 9, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test test code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant