SlideShare a Scribd company logo
1 of 49
Download to read offline
How Shazam works
100+ million users
Happy users 
Even developers?
Android testing
Faster release cycles
Better code
Cheaper 
http://testdroid.com/testdroid/5851
Easy
A user walks into a bar
Doing it the test driven way 
Write 
UI 
test 
Implement 
Refactor 
Write 
unit 
test 
BDD 
TDD
Test first 
• Generally easier 
• Eliminates external dependencies 
• Easily repeatable
The Acceptance Tests cycle 
Write 
UI 
test 
Implement 
Refactor 
Write 
unit 
test 
BDD 
TDD
Acceptance criteria 
• Given: arrange 
• When: act 
• Then: assert
Example 
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 
given(user).isNear(lexington()); 
given(server).returns(lustForLife()); 
when(user).shazams(); 
then(user).canCheckIn(lustForLife(), 
lexington()); 
http://github.com/shazam/gwen
Other libraries for Acceptance Tests 
• Instrumentation 
• JUnit 3 
• Espresso & Robotium 
• Fork 
• HamMock Server
The Unit tests cycle 
Write 
UI 
test 
Implement 
Write 
unit 
Refactor 
test 
BDD 
TDD
What we don’t test 
Activities & Fragments 
http://github.com/xxv/android-lifecycle
What we don’t test
What we do test 
• Presentation logic 
• Business logic 
• That’s it
The MVP pattern 
Presenter 
Model View
The MVP pattern 
Presenter 
Model View 
Android
The MVP pattern 
• Makes presentation logic testable 
• No need to test “dummy” view 
• Avoid Android dependencies
Dependency Injection, Yourself 
• Breaks hardcoded dependencies 
• Behaviour vs Implementation 
• Implementations for test & runtime
Hardcoded dependencies 
Feature X 
Client 
Feature X
Dependency Injection 
Client 
Feature X 
Interface 
Injector
Model 
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 
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 
public 
class 
ResultPresenter 
{ 
ResultPresenter(ResultView 
resultView, 
VenueRetriever 
venueRetriever, 
Result 
result) 
{ 
public 
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 
public 
interface 
ResultView 
{ 
void 
showResult(Result 
track); 
void 
showCheckInPrompt(Venue 
venue); 
}
Activity 
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 
} 
}
Other Unit Test technologies 
• JUnit 4 
• Robolectric 
java.lang.RuntimeException: Stub! 
• Hamcrest 
• JMock
Test execution
Continuous Integration
Speed (Hint: slow)
Usual execution 
Test 
Suite
Spoon 
http://github.com/square/spoon
Fork 
Test 
Suite 
http://github.com/shazam/fork
Example
Fork 
http://github.com/shazam/fork
Fork 
• Pooled execution 
• Infinitely scalable 
• Current setup 1 test / 2 seconds 
http://github.com/shazam/fork
Flakiness monitor
ADB Remote 
http://github.com/sleekweasel/CgiAdbRemote
If all else fails
If all else fails
If all else fails
Summary 
• Testing is easier than you may think 
• Practice, practice, practice 
• Toolset is limited but getting better 
• Ship it!
Questions?

More Related Content

What's hot

Testing for Pragmatic People
Testing for Pragmatic PeopleTesting for Pragmatic People
Testing for Pragmatic People
davismr
 
UI Testing - Selenium? Rich-Clients? Containers? (SwanseaCon 2018)
UI Testing - Selenium? Rich-Clients? Containers? (SwanseaCon 2018)UI Testing - Selenium? Rich-Clients? Containers? (SwanseaCon 2018)
UI Testing - Selenium? Rich-Clients? Containers? (SwanseaCon 2018)
Tobias Schneck
 

What's hot (20)

Unit-testing and E2E testing in JS
Unit-testing and E2E testing in JSUnit-testing and E2E testing in JS
Unit-testing and E2E testing in JS
 
Polyglot automation - QA Fest - 2015
Polyglot automation - QA Fest - 2015Polyglot automation - QA Fest - 2015
Polyglot automation - QA Fest - 2015
 
Web ui tests examples with selenide, nselene, selene & capybara
Web ui tests examples with  selenide, nselene, selene & capybaraWeb ui tests examples with  selenide, nselene, selene & capybara
Web ui tests examples with selenide, nselene, selene & capybara
 
Unit testing on mobile apps
Unit testing on mobile appsUnit testing on mobile apps
Unit testing on mobile apps
 
How to setup unit testing in Android Studio
How to setup unit testing in Android StudioHow to setup unit testing in Android Studio
How to setup unit testing in Android Studio
 
Quickly Testing Qt Desktop Applications
Quickly Testing Qt Desktop ApplicationsQuickly Testing Qt Desktop Applications
Quickly Testing Qt Desktop Applications
 
081107 Sammy Eclipse Summit2
081107   Sammy   Eclipse Summit2081107   Sammy   Eclipse Summit2
081107 Sammy Eclipse Summit2
 
Learn How to Unit Test Your Android Application (with Robolectric)
Learn How to Unit Test Your Android Application (with Robolectric)Learn How to Unit Test Your Android Application (with Robolectric)
Learn How to Unit Test Your Android Application (with Robolectric)
 
Testing for Pragmatic People
Testing for Pragmatic PeopleTesting for Pragmatic People
Testing for Pragmatic People
 
Unit testing and Android
Unit testing and AndroidUnit testing and Android
Unit testing and Android
 
iOS Unit Testing
iOS Unit TestingiOS Unit Testing
iOS Unit Testing
 
UI Testing - Selenium? Rich-Clients? Containers? (SwanseaCon 2018)
UI Testing - Selenium? Rich-Clients? Containers? (SwanseaCon 2018)UI Testing - Selenium? Rich-Clients? Containers? (SwanseaCon 2018)
UI Testing - Selenium? Rich-Clients? Containers? (SwanseaCon 2018)
 
Automated Frontend Testing
Automated Frontend TestingAutomated Frontend Testing
Automated Frontend Testing
 
Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"
 
Unit Testing in iOS
Unit Testing in iOSUnit Testing in iOS
Unit Testing in iOS
 
Unit Testing Android Applications
Unit Testing Android ApplicationsUnit Testing Android Applications
Unit Testing Android Applications
 
Node.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java sideNode.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java side
 
Testing Web Applications
Testing Web ApplicationsTesting Web Applications
Testing Web Applications
 
You do not need automation engineer - Sqa Days - 2015 - EN
You do not need automation engineer  - Sqa Days - 2015 - ENYou do not need automation engineer  - Sqa Days - 2015 - EN
You do not need automation engineer - Sqa Days - 2015 - EN
 
Android Test Pyramid - Ágiles 2013
Android Test Pyramid - Ágiles 2013Android Test Pyramid - Ágiles 2013
Android Test Pyramid - Ágiles 2013
 

Viewers also liked

April 19 social marketing & yr business
April 19 social marketing & yr businessApril 19 social marketing & yr business
April 19 social marketing & yr business
Hack the Hood
 
Lançando versões em um clique - deploy contínuo
Lançando versões em um clique - deploy contínuoLançando versões em um clique - deploy contínuo
Lançando versões em um clique - deploy contínuo
Hélio Medeiros
 
Giving your programs pizzaz and professionalism!
Giving your programs pizzaz and professionalism!Giving your programs pizzaz and professionalism!
Giving your programs pizzaz and professionalism!
Cindy Pao
 

Viewers also liked (20)

The Web is Open. Let's Keep It That Way
The Web is Open. Let's Keep It That WayThe Web is Open. Let's Keep It That Way
The Web is Open. Let's Keep It That Way
 
SXSW 2013: How Twitter is Changing How We Watch TV
SXSW 2013: How Twitter is Changing How We Watch TVSXSW 2013: How Twitter is Changing How We Watch TV
SXSW 2013: How Twitter is Changing How We Watch TV
 
How and why governments should use OpenStreetMap - Pete Lancaster - State of ...
How and why governments should use OpenStreetMap - Pete Lancaster - State of ...How and why governments should use OpenStreetMap - Pete Lancaster - State of ...
How and why governments should use OpenStreetMap - Pete Lancaster - State of ...
 
Data Tiering: Squeezing Scale out of MySQL (LRUG Presentation 2014-01-13)
Data Tiering: Squeezing Scale out of MySQL (LRUG Presentation 2014-01-13)Data Tiering: Squeezing Scale out of MySQL (LRUG Presentation 2014-01-13)
Data Tiering: Squeezing Scale out of MySQL (LRUG Presentation 2014-01-13)
 
Desconf 2012 - Métricas de vaidade
Desconf 2012 - Métricas de vaidadeDesconf 2012 - Métricas de vaidade
Desconf 2012 - Métricas de vaidade
 
March 13 sxsw news entrepreneurs vs trad journalists
March 13 sxsw news entrepreneurs vs trad journalistsMarch 13 sxsw news entrepreneurs vs trad journalists
March 13 sxsw news entrepreneurs vs trad journalists
 
Twitter APIs - the starter guide
Twitter APIs - the starter guideTwitter APIs - the starter guide
Twitter APIs - the starter guide
 
April 19 social marketing & yr business
April 19 social marketing & yr businessApril 19 social marketing & yr business
April 19 social marketing & yr business
 
Prototyping in the cloud
Prototyping in the cloudPrototyping in the cloud
Prototyping in the cloud
 
Getting Comfortable With Child Themes - WordCamp Miami
Getting Comfortable With Child Themes - WordCamp MiamiGetting Comfortable With Child Themes - WordCamp Miami
Getting Comfortable With Child Themes - WordCamp Miami
 
C# - Raise the bar with functional & immutable constructs (Dutch)
C# - Raise the bar with functional & immutable constructs (Dutch)C# - Raise the bar with functional & immutable constructs (Dutch)
C# - Raise the bar with functional & immutable constructs (Dutch)
 
Web Frontend development: tools and good practices to (re)organize the chaos
Web Frontend development: tools and good practices to (re)organize the chaosWeb Frontend development: tools and good practices to (re)organize the chaos
Web Frontend development: tools and good practices to (re)organize the chaos
 
Making Mobile the Default
Making Mobile the DefaultMaking Mobile the Default
Making Mobile the Default
 
Lançando versões em um clique - deploy contínuo
Lançando versões em um clique - deploy contínuoLançando versões em um clique - deploy contínuo
Lançando versões em um clique - deploy contínuo
 
Giving your programs pizzaz and professionalism!
Giving your programs pizzaz and professionalism!Giving your programs pizzaz and professionalism!
Giving your programs pizzaz and professionalism!
 
ChemSpider – disseminating data and enabling an abundance of chemistry platforms
ChemSpider – disseminating data and enabling an abundance of chemistry platformsChemSpider – disseminating data and enabling an abundance of chemistry platforms
ChemSpider – disseminating data and enabling an abundance of chemistry platforms
 
Beyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the codeBeyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the code
 
Rabbits, indians and... Symfony meets queueing brokers
Rabbits, indians and...  Symfony meets queueing brokersRabbits, indians and...  Symfony meets queueing brokers
Rabbits, indians and... Symfony meets queueing brokers
 
Where Values Lead Good People Follow
Where Values Lead Good People FollowWhere Values Lead Good People Follow
Where Values Lead Good People Follow
 
HTTP 2
HTTP 2HTTP 2
HTTP 2
 

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

How to build rock solid apps and keep 100m+ users happy
How to build rock solid apps and keep 100m+ users happyHow to build rock solid apps and keep 100m+ users happy
How to build rock solid apps and keep 100m+ users happy
Iordanis (Jordan) Giannakakis
 

Similar to How to build rock solid apps & keep 100m+ users happy (20)

How to build rock solid apps & keep 100m+ users happy
How to build rock solid apps & keep 100m+ users happyHow to build rock solid apps & keep 100m+ users happy
How to build rock solid apps & keep 100m+ users happy
 
Rcp by example
Rcp by exampleRcp by example
Rcp by example
 
Automated acceptance test
Automated acceptance testAutomated acceptance test
Automated acceptance test
 
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
 
End to-end testing from rookie to pro
End to-end testing  from rookie to proEnd to-end testing  from rookie to pro
End to-end testing from rookie to pro
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
 
Jenkins presentation
Jenkins presentationJenkins presentation
Jenkins presentation
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFX
 
Automated Web Testing using JavaScript
Automated Web Testing using JavaScriptAutomated Web Testing using JavaScript
Automated Web Testing using JavaScript
 
Renaissance of JUnit - Introduction to JUnit 5
Renaissance of JUnit - Introduction to JUnit 5Renaissance of JUnit - Introduction to JUnit 5
Renaissance of JUnit - Introduction to JUnit 5
 
Selenium
SeleniumSelenium
Selenium
 
How to build rock solid apps and keep 100m+ users happy
How to build rock solid apps and keep 100m+ users happyHow to build rock solid apps and keep 100m+ users happy
How to build rock solid apps and keep 100m+ users happy
 
From Web App Model Design to Production with Wakanda
From Web App Model Design to Production with WakandaFrom Web App Model Design to Production with Wakanda
From Web App Model Design to Production with Wakanda
 
Dev ops journey basics and real life
Dev ops journey basics and real lifeDev ops journey basics and real life
Dev ops journey basics and real life
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
 
Testing basics for developers
Testing basics for developersTesting basics for developers
Testing basics for developers
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web Toolkits
 
Jenkins Declarative Pipelines 101
Jenkins Declarative Pipelines 101Jenkins Declarative Pipelines 101
Jenkins Declarative Pipelines 101
 
Performance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle CoherencePerformance Test Driven Development with Oracle Coherence
Performance Test Driven Development with Oracle Coherence
 

Recently uploaded

scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
HenryBriggs2
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 

Recently uploaded (20)

Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptx
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
Air Compressor reciprocating single stage
Air Compressor reciprocating single stageAir Compressor reciprocating single stage
Air Compressor reciprocating single stage
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 

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