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
Tests
Search
Thibaut Coutard
February 10, 2020
Programming
0
46
Tests
1- definitions
2- tools
3- iOS frameworks
Thibaut Coutard
February 10, 2020
Tweet
Share
More Decks by Thibaut Coutard
See All by Thibaut Coutard
iOS ecosystem
coutart
0
24
Clean Architecture
coutart
0
32
Iterate your Klingon
coutart
0
43
Workshop : CI - CD using Bitrise
coutart
0
51
Internationalisation
coutart
0
20
Other Decks in Programming
See All in Programming
Migrating to Signals: A Practical Workshop
manfredsteyer
PRO
0
280
Laravel標準バリデーションでできること
hmb_ok
2
360
GitHub Copilot Tips and Tricks
yuichielectric
26
7.4k
品質が高いコードって何?Rev2.1
ickx
1
490
Creating Retro-Style Photos Using Swift
ski
1
340
Parallel Socket Communication in Swift
s_shimotori
0
220
WinUI 3デモ - "CommunityToolkit.Mvvm"NuGetパッケージ編
andrewkeepcoding
0
130
BuefyのMaintainerを引き継いだ件
kikuomax
0
510
15分間でふんわり理解するDocker @ Matsuriba MAX
ukwhatn
PRO
1
340
コミュニティに参加したことで起きた変化
ohmori_yusuke
3
130
もうすぐ新年度、Babylon.jsがお勧めな3個の理由
hideg
0
160
オブジェクトしこう
okuramasafumi
2
130
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
689
190k
Bash Introduction
62gerente
604
210k
Web development in the modern age
philhawksworth
201
10k
Into the Great Unknown - MozCon
thekraken
10
830
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
19
1.6k
Being A Developer After 40
akosma
56
580k
Gamification - CAS2011
davidbonilla
76
4.5k
Designing on Purpose - Digital PM Summit 2013
jponch
109
6.4k
Designing the Hi-DPI Web
ddemaree
275
33k
Robots, Beer and Maslow
schacon
PRO
154
7.9k
The Language of Interfaces
destraynor
150
23k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
501
140k
Transcript
Tests Thibaut Coutard iOS developer @MobiApps
Why ?
Why ? • More stable applications • Less bugs •
More confidence • Use it as documentation
-Djikstra « Testing shows the presence, not the absence of
bugs »
What kind of tests
Tests pyramid Manual UI Tests Integration Tests Unit tests
Integration Tests UI Tests Manual Cost Unit tests
Unit Test • Individual test • Unit smallest part of
the system • Simplest way to test • Lowest cost • Few seconds
Integration Test • Interaction between components • At least two
or more components • Less tests than UT • Relatively low cost • Seconds/Minutes
UI Test • Test the whole system • Still automated
• Harder to test • Still cheaper than manually • Minutes/Hours
Manual Test • Test the whole system • Hard to
test all cases • Very Expensive • Hours/Days
Feedback loop • Time between creating a bug and fixing
it
Mutation Testing
Mutation Testing
Mutation Testing • Test the tests
TDD Red Green Write failing test Develop Refactor
BDD • Gherkin : Given/When/Then • Understandable by everyone •
Speaks about the user behavior and not the technical behavior • Written with both product, development teams and customer
« What goes in production is the developers understanding »
Tools
Dependency Injection UserInteractor UserDefaults
Dependency Injection UserInteractor UserDefaults
Dependency Injection UserInteractor UserDefaults UserStoreProtocol
Dummy
None
Fake • Return static values
None
Stub • Return values • Can be set during the
test
Stub
Spy • Spy the calls
None
Mock • Return values • Can be set during the
test • Spy the calls
None
Humble Objects ViewController
Humble Objects ViewController Presenter
Humble Objects ViewController Presenter Not testable Testable
Useful libraries
XCTests • Unit test Framework native
XCTests
XCUITest • Native UI Test framework • Record from usage
XCUITest • Native UI Test framework • Record from usage
Nimble • A matcher framework for swift and objective-c •
Easier to read than XCTests
Nimble
Quick • BDD framework for swift and objective-c • Can
be written using the specifications • Easier to read and write
Quick
OHHttpStub • Stub HTTP calls for the whole app •
Helps test API wrappers • Can simulate bad/no network
OHHttpStub • Stub HTTP calls for the whole app •
Helps test API wrappers
KIF • Functional testing • Easier than XCUITests
KIF • Functional testing • Easier than XCUITests
HS : Sourcery • Meta Programming • Generate code •
Awesome AutoMockable template
HS : Sourcery • Meta Programming • Generate code •
Awesome AutoMockable template
Resources • Test Driven iOS Development with Swift 4 •
https://github.com/kif-framework/KIF • https://github.com/Quick/Nimble • https://github.com/Quick/Quick • https://github.com/AliSoftware/OHHTTPStubs