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
66
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
43
BuddyBuild
tiagomartinho
0
38
Daily Journal
tiagomartinho
0
54
Everyone can code
tiagomartinho
0
36
Introduction to Machine Learning
tiagomartinho
0
46
Silicon Valley Tour
tiagomartinho
1
69
Automated User Interface Testing
tiagomartinho
0
64
Swift Peer Lab - try! Swift Tokyo
tiagomartinho
0
89
Francigenr
tiagomartinho
1
35
Other Decks in Technology
See All in Technology
Goss: New Production-Ready Go Binding for Faiss #coefl_go_jp
bengo4com
0
1.1k
Engineering Failure-Resilient Systems
infraplumber0
0
130
キャリアを支え組織力を高める「多層型ふりかえり」 / 20250821 Kazuki Mori
shift_evolve
PRO
2
290
Postman MCP 関連機能アップデート / Postman MCP feature updates
yokawasa
0
120
ZOZOTOWNフロントエンドにおけるディレクトリの分割戦略
zozotech
PRO
14
4.9k
つくって納得、つかって実感! 大規模言語モデルことはじめ
recruitengineers
PRO
9
2.1k
現場が抱える様々な問題は “組織設計上” の問題によって生じていることがある / Team-oriented Organization Design 20250827
mtx2s
1
520
S3のライフサイクル設計でハマったポイント
mkumada
0
140
Autonomous Database Serverless 技術詳細 / adb-s_technical_detail_jp
oracle4engineer
PRO
18
52k
イオン店舗一覧ページのパフォーマンスチューニング事例 / Performance tuning example for AEON store list page
aeonpeople
1
220
LLMエージェント時代に適応した開発フロー
hiragram
1
380
サイボウズフロントエンドの横断活動から考える AI時代にできること
mugi_uno
4
1.4k
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
25
1.8k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Reflections from 52 weeks, 52 projects
jeffersonlam
351
21k
BBQ
matthewcrist
89
9.8k
Scaling GitHub
holman
462
140k
GraphQLとの向き合い方2022年版
quramy
49
14k
A designer walks into a library…
pauljervisheath
207
24k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.4k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
Java REST API Framework Comparison - PWX 2021
mraible
33
8.8k
The Straight Up "How To Draw Better" Workshop
denniskardys
236
140k
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!