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
42
BuddyBuild
tiagomartinho
0
36
Daily Journal
tiagomartinho
0
53
Everyone can code
tiagomartinho
0
35
Introduction to Machine Learning
tiagomartinho
0
45
Silicon Valley Tour
tiagomartinho
1
67
Automated User Interface Testing
tiagomartinho
0
62
Swift Peer Lab - try! Swift Tokyo
tiagomartinho
0
88
Francigenr
tiagomartinho
1
33
Other Decks in Technology
See All in Technology
How Community Opened Global Doors
hiroramos4
PRO
1
110
Agentic Workflowという選択肢を考える
tkikuchi1002
1
480
BigQuery Remote FunctionでLooker Studioをインタラクティブ化
cuebic9bic
3
260
本当に使える?AutoUpgrade の新機能を実践検証してみた
oracle4engineer
PRO
1
140
Liquid Glass革新とSwiftUI/UIKit進化
fumiyasac0921
0
180
GeminiとNotebookLMによる金融実務の業務革新
abenben
0
220
UIテスト自動化サポート- Testbed for XCUIAutomation practice
notoroid
0
130
米国国防総省のDevSecOpsライフサイクルをAWSのセキュリティサービスとOSSで実現
syoshie
2
1k
Prox Industries株式会社 会社紹介資料
proxindustries
0
260
Snowflake Summit 2025 データエンジニアリング関連新機能紹介 / Snowflake Summit 2025 What's New about Data Engineering
tiltmax3
0
300
急成長を支える基盤作り〜地道な改善からコツコツと〜 #cre_meetup
stefafafan
0
120
“社内”だけで完結していた私が、AWS Community Builder になるまで
nagisa53
1
350
Featured
See All Featured
GraphQLの誤解/rethinking-graphql
sonatard
71
11k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.8k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Rebuilding a faster, lazier Slack
samanthasiow
81
9.1k
Designing Experiences People Love
moore
142
24k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.3k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.3k
The World Runs on Bad Software
bkeepers
PRO
69
11k
Java REST API Framework Comparison - PWX 2021
mraible
31
8.6k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
4 Signs Your Business is Dying
shpigford
184
22k
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!