SlideShare ist ein Scribd-Unternehmen logo
1 von 89
Downloaden Sie, um offline zu lesen
뱅크샐러드이병찬
RxTest 같이 시작하기
RxTest, RxBlocking을 같이 알아보기!
뱅크샐러드이병찬
RxTest 같이 시작하기
RxTest, RxBlocking을 같이 알아보기!
1. TestCode, ObservableTestCode란?

2. RxBlocking에 대해

3. RxTest에 대해

4. RxSwift를 테스트해보자!
목차
1. TestCode란?
어떤 동작을 수행 했을 때

1) 원하는 값이 나오는지 검증

2) 연속되어야 하는 동작이 수행되는지 검증
TestCode란?
원하는 값이 나오는지
원하는 값이 나오는지
원하는 값이 나오는지
원하는 값이 나오는지
값이 원하는 형태로 나오는지 검증
연속되어야 하는 동작을 수행하는지
연속되어야 하는 동작을 수행하는지
연속되어야 하는 동작을 수행하는지
연속되어야 하는 동작을 수행하는지
연속되어야 하는 동작을 수행하는지
연속되어야 하는 동작의 수행 검증
그럼 Observable은?
RxTest 새내기 "이뱅샐"
Event를 동기적으로 받을 수는 없을까?
subscribe없이 Event를 받을 수는 없을까?
Hot Observable일 때는?
reduce도 못하는데…
기대하는 타이밍에 Event가 나오는지 검증은?
버튼 눌렀을 때 Event가 나오는지 검증해야 하잖아?
/* Event를 간단하게 추출할 수 있어야 함

/* 원하는 값이 원하는 타이밍에 나오는지 검증
RxBlocking RxTest
어서와, 테스트는 처음이지?
2. RxBlocking
🍏 🍇 🌶 🌽 🍉
🍏 🍇 🌶 🌽 🍉
➜
[ 🍏, 🍇, 🌶, 🌽, 🍉 ]
onComplete가
떨어질 때까지 기다린다…
🍏 🍇 🌶 🌽 🍉
➜
[ 🍏, 🍇, 🌶, 🌽, 🍉 ]
onComplete가 꼭 떨어져야 함
.toBlocking(timeout: RxTimeInterval?)
🍏 🍇 🌶 🌽 🍉
[ 🍏, 🍇, 🌶 ]
➜
- ColdObservable의 Event를 검증할 때 사용

- 특정 시간동안 방출된 Observable의 Event도 검증 가능

• HotObservable도 사용 가능
RxBlocking은
3. RxTest
1초 2초 3초 4초 5초
🍏 🍇 🌶 🌽 🍉
➜
[ (🍏, 1초), (🍇, 2초), (🌶, 3초), (🌽, 4초), (🍉, 5초) ]
➜
3초에 🌶가 나왔는가?
let buttonTapped = s.createHotObservable([
.next(1, Void()),
.next(3, Void())
])
구독의 여부와 상관없이
이벤트 발생
구독이 시작되면
정해진 순서대로 이벤트 발생
1초 2초 3초 4초 5초
🍏 🍇 🌶 🌽 🍉
👀 관찰 👀
➜➜
[ (🍏, 1초), (🍇, 2초), (🌶, 3초), (🌽, 4초), (🍉, 5초) ]
👀 가상의 시간이 모두 흐를 때까지 관찰 👀
👀 가상의 시간이 모두 흐를 때까지 관찰 👀
Observable이 끝나지 않아도 상관X
👀 가상의 시간이 모두 흐를 때까지 관찰 👀
Hot Observable도 테스트 가능!
가상의 시간이 모두 흐를때까지..
- Observable에 시간개념을 넣어줌

• 이를 통해 언제 무엇이 나왔는지 검증 가능

- Observer를 통해 Hot, Cold 모두 검증가능

• 가상의 시간이 다 흐를 때까지 관찰 후 타이밍과 Event 반환
RxTest는?
4. RxSwift를 테스트하자
- 원하는 값이 정상적으로 나오는지 검증

- Response에 상관없이 예상하는 결과가 나오는지
"isLoading" TestCase
✨
- tapped 되었을 때 마다 원하는 값이 정상적으로 나오는지 검증

- Response에 상관없이 예상하는 결과가 나오는지
"loading" TestCase
✨
✨
✨
- Mocking, 가상의 시간, Observer.. 언제 배우나?

- TestCode보다 기능 개발이 더 우선 아니야?
RxBlocking, RxTest....
func removeAllData() {
/* 구현 */
Implements()
}
func removeAllData() {
/* 구현 */
Implements()
}
만약 삭제에서 누락된 데이터가 있다면?
당연하게 동작할 것 같은 코드의 배신
➜
Hotfix
TestCode는

당연한 코드가 당연하게 동작하는지 검증
RxSwift의 TestCode는

Observable이 당연하게 방출되는지 검증
“RxSwift & 테스트코드와 함께 금융의 혁신을
만들어갈 전사들을 뱅샐은 기다립니다.”
- RxTest, RxBlocking

• https://www.raywenderlich.com/7408-testing-your-rxswift-code

• https://github.com/ReactiveX/RxSwift/blob/master/Documentation/UnitTests.md

- Nimble

• https://github.com/Quick/Nimble

- Stubber

• https://github.com/devxoul/Stubber
참고자료
slido.com / #P445
RxSwift Testing 같이 시작하기 feat. RxBlocking, RxTest

Weitere ähnliche Inhalte

Was ist angesagt?

20221131_레츠스위프트_2022_iOS개발에서_알아두면_좋은것들.pdf
20221131_레츠스위프트_2022_iOS개발에서_알아두면_좋은것들.pdf20221131_레츠스위프트_2022_iOS개발에서_알아두면_좋은것들.pdf
20221131_레츠스위프트_2022_iOS개발에서_알아두면_좋은것들.pdf정민 안
 
The Art of Clean code
The Art of Clean codeThe Art of Clean code
The Art of Clean codeVictor Rentea
 
Playwright: A New Test Automation Framework for the Modern Web
Playwright: A New Test Automation Framework for the Modern WebPlaywright: A New Test Automation Framework for the Modern Web
Playwright: A New Test Automation Framework for the Modern WebApplitools
 
A Framework Driven Development
A Framework Driven DevelopmentA Framework Driven Development
A Framework Driven Development정민 안
 
결제를 구현하고 싶은 개발팀을 위한 안내서
결제를 구현하고 싶은 개발팀을 위한 안내서결제를 구현하고 싶은 개발팀을 위한 안내서
결제를 구현하고 싶은 개발팀을 위한 안내서수보 김
 
introduction to Vue.js 3
introduction to Vue.js 3 introduction to Vue.js 3
introduction to Vue.js 3 ArezooKmn
 
Jetpack Compose beginner.pdf
Jetpack Compose beginner.pdfJetpack Compose beginner.pdf
Jetpack Compose beginner.pdfAayushmaAgrawal
 
Getting Started with React.js
Getting Started with React.jsGetting Started with React.js
Getting Started with React.jsSmile Gupta
 
Playwright Begginers Presentation
Playwright Begginers PresentationPlaywright Begginers Presentation
Playwright Begginers PresentationFranPerea6
 
learn what React JS is & why we should use React JS .
learn what React JS is & why we should use React JS .learn what React JS is & why we should use React JS .
learn what React JS is & why we should use React JS .paradisetechsoftsolutions
 
Real Life Clean Architecture
Real Life Clean ArchitectureReal Life Clean Architecture
Real Life Clean ArchitectureMattia Battiston
 
Railway Oriented Programming
Railway Oriented ProgrammingRailway Oriented Programming
Railway Oriented ProgrammingScott Wlaschin
 
Introduction to Coroutines @ KotlinConf 2017
Introduction to Coroutines @ KotlinConf 2017Introduction to Coroutines @ KotlinConf 2017
Introduction to Coroutines @ KotlinConf 2017Roman Elizarov
 
[수정본] 우아한 객체지향
[수정본] 우아한 객체지향[수정본] 우아한 객체지향
[수정본] 우아한 객체지향Young-Ho Cho
 
Let'Swift 2023 iOS 애플리케이션 개발 생산성 고찰
- 정시 퇴근을 위해 우리는 어떻게 해야할 것인가?
Let'Swift 2023 iOS 애플리케이션 개발 생산성 고찰
- 정시 퇴근을 위해 우리는 어떻게 해야할 것인가? Let'Swift 2023 iOS 애플리케이션 개발 생산성 고찰
- 정시 퇴근을 위해 우리는 어떻게 해야할 것인가?
Let'Swift 2023 iOS 애플리케이션 개발 생산성 고찰
- 정시 퇴근을 위해 우리는 어떻게 해야할 것인가? 정민 안
 
Async code on kotlin: rx java or/and coroutines - Kotlin Night Turin
Async code on kotlin: rx java or/and coroutines - Kotlin Night TurinAsync code on kotlin: rx java or/and coroutines - Kotlin Night Turin
Async code on kotlin: rx java or/and coroutines - Kotlin Night TurinFabio Collini
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux IntroductionNikolaus Graf
 
#살아있다 #자프링외길12년차 #코프링2개월생존기
#살아있다 #자프링외길12년차 #코프링2개월생존기#살아있다 #자프링외길12년차 #코프링2개월생존기
#살아있다 #자프링외길12년차 #코프링2개월생존기Arawn Park
 

Was ist angesagt? (20)

20221131_레츠스위프트_2022_iOS개발에서_알아두면_좋은것들.pdf
20221131_레츠스위프트_2022_iOS개발에서_알아두면_좋은것들.pdf20221131_레츠스위프트_2022_iOS개발에서_알아두면_좋은것들.pdf
20221131_레츠스위프트_2022_iOS개발에서_알아두면_좋은것들.pdf
 
The Art of Clean code
The Art of Clean codeThe Art of Clean code
The Art of Clean code
 
Playwright: A New Test Automation Framework for the Modern Web
Playwright: A New Test Automation Framework for the Modern WebPlaywright: A New Test Automation Framework for the Modern Web
Playwright: A New Test Automation Framework for the Modern Web
 
A Framework Driven Development
A Framework Driven DevelopmentA Framework Driven Development
A Framework Driven Development
 
결제를 구현하고 싶은 개발팀을 위한 안내서
결제를 구현하고 싶은 개발팀을 위한 안내서결제를 구현하고 싶은 개발팀을 위한 안내서
결제를 구현하고 싶은 개발팀을 위한 안내서
 
introduction to Vue.js 3
introduction to Vue.js 3 introduction to Vue.js 3
introduction to Vue.js 3
 
Vue Vuex 101
Vue Vuex 101Vue Vuex 101
Vue Vuex 101
 
Jetpack Compose beginner.pdf
Jetpack Compose beginner.pdfJetpack Compose beginner.pdf
Jetpack Compose beginner.pdf
 
Kotlin
KotlinKotlin
Kotlin
 
Getting Started with React.js
Getting Started with React.jsGetting Started with React.js
Getting Started with React.js
 
Playwright Begginers Presentation
Playwright Begginers PresentationPlaywright Begginers Presentation
Playwright Begginers Presentation
 
learn what React JS is & why we should use React JS .
learn what React JS is & why we should use React JS .learn what React JS is & why we should use React JS .
learn what React JS is & why we should use React JS .
 
Real Life Clean Architecture
Real Life Clean ArchitectureReal Life Clean Architecture
Real Life Clean Architecture
 
Railway Oriented Programming
Railway Oriented ProgrammingRailway Oriented Programming
Railway Oriented Programming
 
Introduction to Coroutines @ KotlinConf 2017
Introduction to Coroutines @ KotlinConf 2017Introduction to Coroutines @ KotlinConf 2017
Introduction to Coroutines @ KotlinConf 2017
 
[수정본] 우아한 객체지향
[수정본] 우아한 객체지향[수정본] 우아한 객체지향
[수정본] 우아한 객체지향
 
Let'Swift 2023 iOS 애플리케이션 개발 생산성 고찰
- 정시 퇴근을 위해 우리는 어떻게 해야할 것인가?
Let'Swift 2023 iOS 애플리케이션 개발 생산성 고찰
- 정시 퇴근을 위해 우리는 어떻게 해야할 것인가? Let'Swift 2023 iOS 애플리케이션 개발 생산성 고찰
- 정시 퇴근을 위해 우리는 어떻게 해야할 것인가?
Let'Swift 2023 iOS 애플리케이션 개발 생산성 고찰
- 정시 퇴근을 위해 우리는 어떻게 해야할 것인가?
 
Async code on kotlin: rx java or/and coroutines - Kotlin Night Turin
Async code on kotlin: rx java or/and coroutines - Kotlin Night TurinAsync code on kotlin: rx java or/and coroutines - Kotlin Night Turin
Async code on kotlin: rx java or/and coroutines - Kotlin Night Turin
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
 
#살아있다 #자프링외길12년차 #코프링2개월생존기
#살아있다 #자프링외길12년차 #코프링2개월생존기#살아있다 #자프링외길12년차 #코프링2개월생존기
#살아있다 #자프링외길12년차 #코프링2개월생존기
 

RxSwift Testing 같이 시작하기 feat. RxBlocking, RxTest