Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Testing and Continuous Integration in iOS
Search
Tiago Martinho
July 04, 2017
Technology
0
64
Testing and Continuous Integration in iOS
Tiago Martinho
July 04, 2017
Tweet
Share
More Decks by Tiago Martinho
See All by Tiago Martinho
Time Managment
tiagomartinho
0
41
BuddyBuild
tiagomartinho
0
35
Daily Journal
tiagomartinho
0
52
Everyone can code
tiagomartinho
0
33
Introduction to Machine Learning
tiagomartinho
0
43
Silicon Valley Tour
tiagomartinho
1
64
Automated User Interface Testing
tiagomartinho
0
60
Swift Peer Lab - try! Swift Tokyo
tiagomartinho
0
85
Francigenr
tiagomartinho
1
33
Other Decks in Technology
See All in Technology
深層学習と3Dキャプチャ・3Dモデル生成(土木学会応用力学委員会 応用数理・AIセミナー)
pfn
PRO
0
360
Fearsome File Formats
ange
0
550
[トレノケ雲の会 mod.13] 3回目のre:Inventで気づいたこと -CloudOperationsを添えて-
shintaro_fukatsu
0
120
Formal Development of Operating Systems in Rust
riru
1
320
I could be Wrong!! - Learning from Agile Experts
kawaguti
PRO
8
1.7k
開発生産性向上! 育成を「改善」と捉えるエンジニア育成戦略
shoota
2
820
怖くない!ゼロから始めるPHPソースコードコンパイル入門
colopl
0
230
pg_bigmをRustで実装する(第50回PostgreSQLアンカンファレンス@オンライン 発表資料)
shinyakato_
0
150
スケールし続ける事業とサービスを支える組織とアーキテクチャの生き残り戦略 / The survival strategy for Money Forward’s engineering.
moneyforward
0
210
AWS re:Invent 2024 Recap in ZOZO - Serverless で好きなものをしゃべってみた
chongmyungpark
0
960
シフトライトなテスト活動を適切に行うことで、無理な開発をせず、過剰にテストせず、顧客をビックリさせないプロダクトを作り上げているお話 #RSGT2025 / Shift Right
nihonbuson
3
950
「完全に理解したTalk」完全に理解した
segavvy
1
270
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Site-Speed That Sticks
csswizardry
2
210
VelocityConf: Rendering Performance Case Studies
addyosmani
327
24k
Unsuck your backbone
ammeep
669
57k
YesSQL, Process and Tooling at Scale
rocio
170
14k
Producing Creativity
orderedlist
PRO
343
39k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
BBQ
matthewcrist
85
9.4k
Measuring & Analyzing Core Web Vitals
bluesmoon
5
190
Designing for humans not robots
tammielis
250
25k
A Philosophy of Restraint
colly
203
16k
Transcript
Tiago Martinho @martinho_t tiagomartinho Testing and Continuous Integration in iOS
Agenda (Testing) • Motivation • Unit Testing • TDD in
iOS • Clean Architecture • UI Testing • Alternatives Frameworks • Other Types of Testing 2
Motivation 3
Motivation • Confidence • Regressions • Executable Documentation • Testable
& Clean Design 4
Unit Testing 5
6 Structure of a Unit Test func testArraySorting() { let
input = [1, 7, 6, 3, 10] let output = input.sorted() XCTAssertEqual(output, [1, 3, 6, 7, 10]) } https://developer.apple.com/videos/play/wwdc2017/414/
7 Structure of a Unit Test func testArraySorting() { let
input = [1, 7, 6, 3, 10] let output = input.sorted() XCTAssertEqual(output, [1, 3, 6, 7, 10]) } input https://developer.apple.com/videos/play/wwdc2017/414/
8 Structure of a Unit Test func testArraySorting() { let
input = [1, 7, 6, 3, 10] let output = input.sorted() XCTAssertEqual(output, [1, 3, 6, 7, 10]) } Array.sorted input https://developer.apple.com/videos/play/wwdc2017/414/
9 Structure of a Unit Test func testArraySorting() { let
input = [1, 7, 6, 3, 10] let output = input.sorted() XCTAssertEqual(output, [1, 3, 6, 7, 10]) } Array.sorted input output https://developer.apple.com/videos/play/wwdc2017/414/
10 Structure of a Unit Test Array.sorted input output https://developer.apple.com/videos/play/wwdc2017/414/
11 Structure of a Unit Test Prepare input Array.sorted input
output https://developer.apple.com/videos/play/wwdc2017/414/
12 Structure of a Unit Test Prepare input Run the
code being tested Array.sorted input output https://developer.apple.com/videos/play/wwdc2017/414/
13 Structure of a Unit Test Prepare input Run the
code being tested Verify output Array.sorted input output https://developer.apple.com/videos/play/wwdc2017/414/
“3-As" Pattern • Arrange • Act • Assert 14
XCTest • Xcode’s testing framework • Create and run unit
tests, performance tests, and UI tests for your Xcode project. 15
16 New Xcode Project with Unit Tests Hello XCTest
TDD 17
18 Red Green Refactor
19 Write a failing test Green Refactor
20 Red Make the test pass Refactor
21 Red Green Improve the code
22 http://agilekatas.co.uk/katas/RockPaperScissors-Kata Programming Kata
23 Characteristics of Testable Code https://developer.apple.com/videos/play/wwdc2017/414/
24 Characteristics of Testable Code Control over inputs https://developer.apple.com/videos/play/wwdc2017/414/
25 Characteristics of Testable Code Control over inputs Visibility into
outputs https://developer.apple.com/videos/play/wwdc2017/414/
26 Characteristics of Testable Code Control over inputs Visibility into
outputs No hidden state https://developer.apple.com/videos/play/wwdc2017/414/
27 https://github.com/emilybache/Racing-Car-Katas Hard to test code
28 Testability Techniques Protocols and parameterization Separating logic and effects
https://developer.apple.com/videos/play/wwdc2017/414/
Clean Architecture 29
Structure of the application 30 Framework Dependent Framework API Replaceable
Not essential Sensor View … Database
Structure of the application 31 Framework Independent Service Presenter …
Repository Use Cases Heart of the application Essential
Structure of the application 32 Framework Dependent Framework Independent Sensor
View … Database Service Presenter … Repository ? ?
Structure of the application 33 Framework Dependent Framework Independent View
Presenter Interfaces The interfaces should be written in terms of our domain
Structure of the application 34 Framework Dependent Framework Independent View
Presenter Protocols In Swift interfaces are defined as Protocols
Practical Example 35
Practical Example Login App 36 Login Screen Main Screen
Practical Example 37 LoginViewController xib, storyboard, code extends UIViewController View
Practical Example 38 LoginViewController Framework Dependent (UIKit) View
Practical Example 39 LoginViewController View LoginPresenter LoginService
Practical Example 40 LoginViewController View LoginPresenter LoginService Framework Independent
Practical Example 41 LoginViewController View LoginPresenter LoginService Easy to: -Test
-Port -Maintain
Practical Example Collaborators objects are injected 42 LoginPresenter LoginView a
LoginView a LoginService LoginService
43 https://github.com/elit-software/login-screen Framework Independent App
UI Testing 44
45 Core Technologies + Accessibility XCTest https://developer.apple.com/videos/play/wwdc2015/406/
46 https://github.com/elit-software/login-screen Hello UI Testing
Alternative Testing Frameworks 47
Quick + Nimble 48 https://github.com/Quick
KIF - Keep It Functional iOS Integration Testing Framework 49
https://github.com/kif-framework/KIF
Open source test automation framework for use with native, hybrid
and mobile web apps. It drives iOS, Android, and Windows apps using the WebDriver protocol. 50 http://appium.io
EarlGrey Google iOS UI Automation Test Framework 51 https://github.com/google/EarlGrey
Calabash Automated acceptance testing for mobile apps 52 http://calaba.sh
Other Types of Testing 53
Asynchronous Testing 54 https://developer.apple.com/documentation/xctest/ asynchronous_tests_and_expectations/ testing_asynchronous_operations_with_expectations
Performance Testing 55 https://developer.apple.com/library/content/documentation/ Performance/Conceptual/EnergyGuide-iOS/ TestPerformance.html
Property-Based Testing 56 https://github.com/typelift/SwiftCheck
Continuous Integration 57
Agenda • Definition • Motivation • Continuous Deployment • Services
• Setup 58
Definition • Integrate code into a shared repository several times
a day 59
Motivation • Risk Reduction • Build and Deploy Automation •
Tested Builds Available • Build and Test Results 60
“Every 3 weeks, we polish up the Pinterest app to
make it faster and better than ever.” “To make our app better for you, we bring updates to the App Store every 2 weeks” 61
62 Jenkins
63
64 Pipeline
65 fastlane
66
67
68 Setup a Project with BuddyBuild
Other References https://developer.apple.com/videos/play/wwdc2015/406/ https://developer.apple.com/videos/play/wwdc2017/414/ http://alistair.cockburn.us/Hexagonal+architecture https://www.objc.io/issues/13-architecture/viper/ http://matteo.vaccari.name/blog/archives/154 http://www.dossier-andreas.net/software_architecture/ports_and_adapters.html http://www.growing-object-oriented-software.com http://www.natpryce.com/articles/000772.html
https://www.youtube.com/watch?v=RLo6hs1uDLA https://developer.apple.com/videos/play/wwdc2015/408/ 69
Slides https:// speakerdeck.com/ tiagomartinho/testing- and-continuous- integration-in-ios# 70
Tiago Martinho @martinho_t tiagomartinho Thank you!