SlideShare ist ein Scribd-Unternehmen logo
1 von 49
Downloaden Sie, um offline zu lesen
How to build rock-solid apps and
keep 100m+ users happy
Iordanis Giannakakis
About me
• Iordanis “Jordan” Giannakakis
• Android Team Lead at Shazam
• @iordanis_g
@iordanis_g
How Shazam works
@iordanis_g
100+ million users
@iordanis_g
Happy users
@iordanis_g
Even developers?
Android testing
@iordanis_g
Faster release cycles
@iordanis_g
Better code
@iordanis_g
Cheaper
@iordanis_g
http://testdroid.com/testdroid/5851
Easy
@iordanis_g
A user walks into a bar...
@iordanis_g
Doing it the test-driven way
@iordanis_g
Write
UI test
Implement
Refactor
Write unit
test
BDD
TDD
“To TDD or not to TDD?
@iordanis_g
...That is not the question”
Seb Rose
http://claysnow.co.uk/to-tdd-or-not-to-tdd/
Test-first
@iordanis_g
• Generally easier
• Eliminates external dependencies
• Easily repeatable
The Acceptance tests cycle
@iordanis_g
Write
UI test
Implement
Refactor
Write unit
test
BDD
TDD
Acceptance criteria
@iordanis_g
Given: arrange
When: act
Then: assert
Example
@iordanis_g
Given a user is near a music venue
And the server always returns a known result
When the user Shazams
Then the user can check-in their discovery
gwen
@iordanis_g
given(user).isNear(lexington())
given(server).returns(lustForLife())
when(user).shazams()
then(user).canCheckIn(lustForLife(), lexington())
https://github.com/shazam/gwen
Acceptance tests technologies
@iordanis_g
• Instrumentation
• JUnit 3
• Robotium & Espresso
• gwen
• HamMock Server
The Unit tests cycle
@iordanis_g
Write
UI test
Implement
Refactor
Write unit
test
BDD
TDD
What we don’t test
@iordanis_g
Activities & Fragments
https://github.com/xxv/android-lifecycle/
What we don’t test
@iordanis_g
What we do unit test
@iordanis_g
• Presentation logic
• Business logic
• That’s all!
The MVP pattern
@iordanis_g
Presenter
Model View
The MVP pattern, for Android
@iordanis_g
Presenter
Model
View
start
stop
Android
The MVP pattern
@iordanis_g
• Makes presentation logic testable
• No need to test the “slave” view
• Avoid Android dependencies
Dependency Injection, Yourself (DIY)
@iordanis_g
• Break hardcoded dependencies
• Behaviour vs implementation
• Swappable dependencies for test and
production runtimes
Hard-coded dependencies
@iordanis_g
Client
Feature X Feature X
Dependency Injection
@iordanis_g
Client
Injector
Feature X
Interface
Model
@iordanis_g
public interface VenueRetriever {
void findClosestVenue(VenueFoundCallback callback);
}
public class NetworkVenueRetriever implements VenueRetriever {
public void findClosestVenue(VenueFoundCallback callback) {
// Some slow networking
}
}
public class LocalVenueRetriever implements VenueRetriever {
public void findClosestVenue(VenueFoundCallback callback) {
// DB look-up / caching layer, perhaps?
}
}
Activity
@iordanis_g
public class ResultActivity extends Activity implements ResultView {
private final VenueRetriever venueRetriever;
private ResultPresenter resultPresenter;
public ResultActivity() {
venueRetriever = venueRetriever();
}
public void onCreate(Bundle savedInstanceState) {
// TODO: Setup layouts & views
Result result = resultToDisplay();
resultPresenter = new ResultPresenter(this, venueRetriever, result);
}
public void onStart() {
resultPresenter.startPresenting();
}
}
Presenter
@iordanis_g
public class ResultPresenter {
public ResultPresenter(ResultView resultView, VenueRetriever
venueRetriever, Result result) {
this.resultView = resultView;
this.venueRetriever = venueRetriever;
this.result = result;
}
public void startPresenting() {
resultView.showResult(result);
venueRetriever.findClosestVenue(new VenueFoundCallback() {
public void venueFound(Venue venue) {
resultView.showCheckInPrompt(venue);
}
});
}
}
View
@iordanis_g
public interface ResultView {
void showResult(Result track);
void showCheckInPrompt(Venue venue);
}
Activity
@iordanis_g
public class ResultActivity extends Activity implements ResultView {
public void showResult(Result result) {
//TODO show the result screen & bind result data
}
public void showCheckInPrompt(Venue venue) {
//TODO bind the venue with check-in prompt view
}
}
Unit tests technologies
@iordanis_g
• JUnit 4
• Robolectric
java.lang.RuntimeException: Stub!
• Hamcrest
• JMock
Test execution
@iordanis_g
Continuous Integration
@iordanis_g
Speed (Hint: slow)
@iordanis_g
Usual execution
@iordanis_g
Test Suite
Spoon
@iordanis_g
http://square.github.io/spoon/
Fork
@iordanis_g
Test Suite
Fork
@iordanis_g
• Inspired by Spoon, but faster
• Infinitely scalable
• Current setup 1 test / 2 secs
• Pooled execution
Flakiness monitor
@iordanis_g
ADB Remote
@iordanis_g
https://github.com/sleekweasel/CgiAdbRemote
If all else fails...
@iordanis_g
If all else fails...
@iordanis_g
If all else fails...
@iordanis_g
Summary
@iordanis_g
• Testing is easier than you may think
• Practice, practice, practice
• Toolset is limited
• Ship it!
@iordanis_g
Questions?
Hiring...

Weitere ähnliche Inhalte

Ähnlich wie How to build rock solid apps and keep 100m+ users happy

Rapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 PlatformRapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 Platform
WSO2
 

Ähnlich wie How to build rock solid apps and keep 100m+ users happy (20)

Testcontainers - Geekout EE 2017 presentation
Testcontainers - Geekout EE 2017 presentationTestcontainers - Geekout EE 2017 presentation
Testcontainers - Geekout EE 2017 presentation
 
My way to clean android - Android day salamanca edition
My way to clean android - Android day salamanca editionMy way to clean android - Android day salamanca edition
My way to clean android - Android day salamanca edition
 
Webdriver with Thucydides - TdT@Cluj #18
Webdriver with Thucydides - TdT@Cluj #18Webdriver with Thucydides - TdT@Cluj #18
Webdriver with Thucydides - TdT@Cluj #18
 
Building native Android applications with Mirah and Pindah
Building native Android applications with Mirah and PindahBuilding native Android applications with Mirah and Pindah
Building native Android applications with Mirah and Pindah
 
Rapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 PlatformRapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 Platform
 
YUI 3
YUI 3YUI 3
YUI 3
 
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
 
Marvel of Annotation Preprocessing in Java by Alexey Buzdin
Marvel of Annotation Preprocessing in Java by Alexey BuzdinMarvel of Annotation Preprocessing in Java by Alexey Buzdin
Marvel of Annotation Preprocessing in Java by Alexey Buzdin
 
Trimming The Cruft
Trimming The CruftTrimming The Cruft
Trimming The Cruft
 
Tdd & clean code
Tdd & clean codeTdd & clean code
Tdd & clean code
 
Desarrollo para Android con Groovy
Desarrollo para Android con GroovyDesarrollo para Android con Groovy
Desarrollo para Android con Groovy
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principles
 
Developer Tests - Things to Know
Developer Tests - Things to KnowDeveloper Tests - Things to Know
Developer Tests - Things to Know
 
What’s new in Google Dart - Seth Ladd
What’s new in Google Dart - Seth LaddWhat’s new in Google Dart - Seth Ladd
What’s new in Google Dart - Seth Ladd
 
Droidcon ES '16 - How to fail going offline
Droidcon ES '16 - How to fail going offlineDroidcon ES '16 - How to fail going offline
Droidcon ES '16 - How to fail going offline
 
Android networking-2
Android networking-2Android networking-2
Android networking-2
 
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
Breaking Dependencies To Allow Unit Testing - Steve Smith | FalafelCON 2014
 
Breaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit TestingBreaking Dependencies to Allow Unit Testing
Breaking Dependencies to Allow Unit Testing
 
3 WAYS TO TEST YOUR COLDFUSION API -
3 WAYS TO TEST YOUR COLDFUSION API - 3 WAYS TO TEST YOUR COLDFUSION API -
3 WAYS TO TEST YOUR COLDFUSION API -
 
3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API
 

Kürzlich hochgeladen

Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
dharasingh5698
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Kürzlich hochgeladen (20)

Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 

How to build rock solid apps and keep 100m+ users happy