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
増え続ける脆弱性に立ち向かう: 事前対策と優先度づけによる 持続可能な脆弱性管理 / Confronting the Rise of Vulnerabilities: Sustainable Management Through Proactive Measures and Prioritization
nttcom
0
130
「現場で活躍するAIエージェント」を実現するチームと開発プロセス
tkikuchi1002
6
1k
AI時代にも変わらぬ価値を発揮したい: インフラ・クラウドを切り口にユーザー価値と非機能要件に向き合ってエンジニアとしての地力を培う
netmarkjp
0
220
TypeScript 上達の道
ysknsid25
4
480
Bill One 開発エンジニア 紹介資料
sansan33
PRO
4
13k
Shadow DOMとセキュリティ - 光と影の境界を探る / Shibuya.XSS techtalk #13
masatokinugawa
0
270
TROCCO今昔
gtnao
0
210
Snowflake のアーキテクチャは本当に筋がよかったのか / Data Engineering Study #30
indigo13love
0
250
MCPと認可まわりの話 / mcp_and_authorization
convto
1
110
AI工学特論: MLOps・継続的評価
asei
10
1.5k
公開初日に個人環境で試した Gemini CLI 体験記など / Gemini CLI実験レポート
you
PRO
3
310
DATA+AI SummitとSnowflake Summit: ユーザから見た共通点と相違点 / DATA+AI Summit and Snowflake Summit
nttcom
0
210
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
357
30k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
8
710
A designer walks into a library…
pauljervisheath
207
24k
A better future with KSS
kneath
238
17k
Optimising Largest Contentful Paint
csswizardry
37
3.3k
Bash Introduction
62gerente
613
210k
Testing 201, or: Great Expectations
jmmastey
43
7.6k
Gamification - CAS2011
davidbonilla
81
5.4k
Java REST API Framework Comparison - PWX 2021
mraible
31
8.7k
What's in a price? How to price your products and services
michaelherold
246
12k
GitHub's CSS Performance
jonrohan
1031
460k
Adopting Sorbet at Scale
ufuk
77
9.5k
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!