27
김지혁 Developer of Flitto Jihyok Kim UI Test 연동으로 배포 두려움 없애기

UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

Embed Size (px)

Citation preview

Page 1: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

김지혁Developer of Flitto

Jihyok Kim

UI Test 연동으로 배포 두려움 없애기

Page 2: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

실제 개발자들의 마음이 반영

어떻게 방지?

개발자의 속마음

Page 3: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

수동 테스트우리는 개발자효율적으로 Scale Up

테스트 또 테스트

Page 4: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

CI, Espresso, Dagger2, Mockito, Firebase Test Lab

새로운 기능 개발버그 수정

기능 개발

안전하게 기능 및 버그 수정 배포

배포

필수 기능 점검

Mock UI Testing

성능 저하 확인 및 방지

Performance Testing

최소 단위 테스팅코어 모듈 점검

Unit Testing

Page 5: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

배포 프로세스 공유 및 개선

안드로이드 테스팅 설계 및 시행착오

이번 발표에 포함되는 내용

앞으로 개발 방향

Page 6: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

악명 높은 안드로이드 단위 테스트 Context 분리

스파게티 코드 제거

Fast and Unfragile로직의 근간: 코드는 틀리지 않는다

Unit Testing

Product Development Unit Testing Mock UI

Testing ReleasePerformance Testing

Page 7: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

화면 노출시 API 호출 이후 화면에 내용 렌더링 에러시 토스트로 알림

View의 역할은?

Presenter의 역할은?

Unit Testing: 시나리오

Product Development Unit Testing Mock UI

Testing ReleasePerformance Testing

Page 8: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

View의 역할

Product Development Unit Testing Mock UI

Testing ReleasePerformance Testing

Page 9: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

Presenter의 역할

Product Development Unit Testing Mock UI

Testing ReleasePerformance Testing

Page 10: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

Unit Testing 준비: Triple A Testing

Product Development Unit Testing Mock UI

Testing ReleasePerformance Testing

ArrangeGiven Valid Post URL is Returned

ActWhen View is Attached

AssertShould Correctly Render with Valid Data

Page 11: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

Product Development Unit Testing Mock UI

Testing ReleasePerformance Testing

Given Valid Post URL is Returned When View is AttachedShould Correctly Render with Valid Data

Page 12: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

Circle.yml 생성Base Directory공식 문서에 제공되는 스크립트에서 조금 수정

Circle CI 연동

Product Development Unit Testing Mock UI

Testing ReleasePerformance Testing

Page 13: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

UI Testing

Product Development Unit Testing Mock UI

Testing ReleasePerformance Testing

Espresso 공식 지원

무작정 UI 테스트 설계시UI 테스트 수백개네트워크 환경 불안정, 기능 변경 등유지보수 포인트 추가

Page 14: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

Dagger2를 통한 의존성 주입

Product Development Unit Testing Mock UI

Testing ReleasePerformance Testing

안정성을 위해 UI 테스트시 가짜 객체 주입

상용 코드에 최대한 영향을 주지 않게

Page 15: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

Dagger2 모듈 재구성

Product Development Unit Testing Mock UI

Testing ReleasePerformance Testing

Application Component

Mock ApplicationComponent

Mock Application Module

Mock Network Module Network Module Application ModulePresenter Module

Page 16: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

Activity Test Rule 통해 원하는 시점에서 콜백

Product Development Unit Testing Mock UI

Testing ReleasePerformance Testing

Page 17: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

환경에 맞는 Mock Dependencies 주입

Product Development Unit Testing Mock UI

Testing ReleasePerformance Testing

Page 18: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

Espresso를 이용해서 테스트 케이스 작성

Product Development Unit Testing Mock UI

Testing ReleasePerformance Testing

Espresso Cheat Sheet: https://developer.android.com/training/testing/espresso/cheat-sheet.html

Page 19: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

Android Test Gradle Dependencies

Product Development Unit Testing Mock UI

Testing ReleasePerformance Testing

Page 20: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

Firebase Test Lab

Product Development Unit Testing Mock UI

Testing ReleasePerformance Testing

로컬 환경에서 남는 노트북으로 세팅 가능

안정적 테스팅 환경을 위해 Test Lab 이용

로그, 영상, CPU 및 메모리 성능 확인 가능

Page 21: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

Firebase Test Lab 설계 순서

Product Development Unit Testing Mock UI

Testing ReleasePerformance Testing

CI 환경에서 AndroidTest apk를 빌드한다

저장해둔 Gcloud 서비스 키를 이용해서 firebase 에 업로드 한다

결과값을 받아서 개발자들에게 노티를 보낸다

Page 22: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

앞으로 방향: 성능 테스트

Product Development Unit Testing Mock UI

Testing ReleasePerformance Testing

스크롤시 평균 FPS

Cold Start Time

Page 23: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

평균 FPS

Product Development Unit Testing Mock UI

Testing ReleasePerformance Testing

스크롤시 평균 FPS 값 계산

24 FPS -> Fluid Motion

30 ~ 60 FPS: 차이 못느낌

Page 24: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

Tiny Dancer 연동

Product Development Unit Testing Mock UI

Testing ReleasePerformance Testing

Page 25: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

Cold Start Time

Product Development Unit Testing Mock UI

Testing ReleasePerformance Testing

앱이 커질수록 초기에 세팅 방대

reportFullyDrawn() 메소드를 통해서 접근

UI 테스트와 동시에 진행

Page 26: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

진입장벽이 높고, 우선순위에 밀리지만개선된 프로세스를 통해 품질 향상이 가능하다고로, 테스팅을 합시다!

발표에 사용된 코드는 모두 깃허브에서 확인 가능하다 https://github.com/wotomas/NewYorkTimesMVP

Page 27: UI Test 연동으로 배포 두려움 없애기: CI, Espresso, Dagger2, Mockito, Firebase Test Lab

많이 지원해주세요!