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
56
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
33
BuddyBuild
tiagomartinho
0
29
Daily Journal
tiagomartinho
0
49
Everyone can code
tiagomartinho
0
28
Introduction to Machine Learning
tiagomartinho
0
40
Silicon Valley Tour
tiagomartinho
1
51
Automated User Interface Testing
tiagomartinho
0
52
Swift Peer Lab - try! Swift Tokyo
tiagomartinho
0
65
Francigenr
tiagomartinho
1
31
Other Decks in Technology
See All in Technology
Building a RAG-poweredAI chat appwith Python and VS Code
pamelafox
0
140
いいたいことちゃんという
tkengo
0
230
家族アルバム みてねにおけるGrafana活用術 / Grafana Meetup Japan Vol.1 LT
isaoshimizu
1
910
コードファーストの考え方。 Amplify Gen2から学ぶAWS次世代のWeb開発体験
yoshiitaka
1
280
AWSに詳しくない人でも始められるコスト最適化ガイド
yuhta28
2
280
Azureの基本的な権限管理の勉強会
yhana
1
2k
require(ESM)とECMAScript仕様
uhyo
4
950
リテール金融(キャッシュレス・ネット銀行・ネット証券)の競争環境と経済圏
8maki
0
1.5k
推しは推せるときに推せ! プロダクトにフィードバックしていこう
nakasho
0
450
地理空間データ可視化・解析・活用ソリューション Pacific Spatial Solutions (PSS)
pacificspatialsolutions
0
330
GrafanaMeetup_AmazonManagedGrafanaのアクセス制御機能とマルチテナント環境下でのアクセス制御について
daitak
0
390
【SORACOM UG 東海】あらゆるモノがつながる社会へ、IoT と SORACOM
soracom
PRO
1
140
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
244
12k
The Power of CSS Pseudo Elements
geoffreycrofte
61
5k
The Pragmatic Product Professional
lauravandoore
26
5.8k
Become a Pro
speakerdeck
PRO
12
4.6k
Building Better People: How to give real-time feedback that sticks.
wjessup
356
18k
A Philosophy of Restraint
colly
197
16k
Build your cross-platform service in a week with App Engine
jlugia
226
17k
Making the Leap to Tech Lead
cromwellryan
125
8.5k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
660
120k
5 minutes of I Can Smell Your CMS
philhawksworth
199
19k
Testing 201, or: Great Expectations
jmmastey
29
6.4k
No one is an island. Learnings from fostering a developers community.
thoeni
16
2.1k
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!