SlideShare una empresa de Scribd logo
1 de 66
Descargar para leer sin conexión
Unit	testing on	Android:
why and how?
DevFest Bucharest
Danny	Preussler
@PreusslerBerlin
Untested	Code is	the	Dark	Matter	of	Software
'El	Gordo'	Galaxy	Cluster	Even	Bigger	Than	Thought	(NASA,	Chandra,	04/03/14)	by	NASA's	Marshall	Space	Flight	Center,	CC	by	2.0;	flickr.com/photos/nasamarshall/13901530984
it	makes	up	to 90%
of	the	software	universe
Untested	Code is	the	Dark	Matter	of	Software
'El	Gordo'	Galaxy	Cluster	Even	Bigger	Than	Thought	(NASA,	Chandra,	04/03/14)	by	NASA's	Marshall	Space	Flight	Center,	CC	by	2.0;	flickr.com/photos/nasamarshall/13901530984
How	do	we	test
our	apps	today?
http://martinfowler.com/bliki/TestPyramid.html
Manual
UI
Service
Unit
Champ!®	Mini	Swirls	Birthday	Party	Ice	Cream	Cones	by	Blue	Bunny®,	CC	by	2.0;	www.flickr.com/photos/bluebunnyicecream/5449137794
http://martinfowler.com/bliki/TestPyramid.html
The	problem of
functional	tests
Something is	broken!
@PreusslerBerlin
What	is	broken?
@PreusslerBerlin
Where	it’s	broken?
@PreusslerBerlin
It’s	end	to	end by	definition!
@PreusslerBerlin
Production	failures
https://www.usenix.org/system/files/conference/osdi14/osdi14-paper-yuan.pdf
77%	of	the	failures	
could	be reproduced	
by	a	unit	test
@PreusslerBerlin
74%	of	the	failures	
are	deterministic
@PreusslerBerlin
58%	of	the	catastrophic	failures	
where	error	handling
@PreusslerBerlin
st	by	PROTerry Johnston,	 CC	by	2.0;	flickr.com/photos/powerbooktrance/466709245
Fear	by	PRObrx0;	CC	by	2.0;	flickr.com/photos/atul666/5429073525
Documentation!
mutually	by	Bruce	Denis;	CC	by	2.0;	flickr.com/photos/f2point8/5896153192
Unit	tests	
slow me	down!?
Unit	tests	
slow me	down!?
Feature	development	
will	slow	down	
long	term
@PreusslerBerlin
Customers	will	loose	trust
@PreusslerBerlin
Code	written	in	rush	
will	be	thrown	away
@PreusslerBerlin
The	next	developer	
will	throw	it away
@PreusslerBerlin
The	value	that	separates	amateurs	from	
professionals	is	that	velocity	is	a	direct	function	
of	quality.
The	value	that	separates	amateurs	from	professionals	is	
that	velocity	is	a	direct	function	of	quality.	
Novices	believe	..	that	hacking	is	fast.
The	value	that	separates	amateurs	from	professionals	is	
that	velocity	is	a	direct	function	of	quality.	
Novices	believe	..	that	hacking	is	fast.
The	higher	the	quality,	the	faster	you	go.
The	value	that	separates	amateurs	from	professionals	is	
that	velocity	is	a	direct	function	of	quality.	
Novices	believe	..	that	hacking	is	fast.
The	higher	the	quality,	the	faster	you	go.
Every	time	you	trade	quality	for	speed,	you	slow	
down.	Every	time.
- Uncle	Bob
YOU are	the	expert!
@PreusslerBerlin
Don’t	let	someone	
tell	YOU how	to	code!
@PreusslerBerlin
The	only way	to	go	fast
is	to	go	well
@PreusslerBerlin
@PreusslerBerlin
Be	professional!
@PreusslerBerlin
YOU are	not	paid	
to	write legacy	code
@PreusslerBerlin
Don’t	ship	crap!
@PreusslerBerlin
Your	test code	
is	more	important	
than	production	code
@PreusslerBerlin
But	how	do	we	start?
Write	testable	code
@PreusslerBerlin
Inversion	of	Control
@PreusslerBerlin
void doSomething() {
new Something().doWhatISay();
}
Not	testable!
void doSomething(Something something) {
something.doWhatISay();
}
class MyClass {
@Inject Something something;
void doSomething() {
something.doWhatISay();
}
} Dependency	
Injection
Single responsibilities
Clean Code
@PreusslerBerlin
Respect	Law	of	Demeter
http://enterprisecraftsmanship.com/2016/09/29/law-of-demeter-and-immutability/ @PreusslerBerlin
Avoid	static
@PreusslerBerlin
Avoid singletons
@PreusslerBerlin
Wrap	all	the	things
@PreusslerBerlin
But	what	about	
Legacy	Code?
New features	
must	have	tests!
@PreusslerBerlin
Investigate	bugs	with
exploratory	tests
@PreusslerBerlin
Explore	code	with	
characterization	tests
@PreusslerBerlinhttps://michaelfeathers.silvrback.com/characterization-testing
Tests	will	change	
your	architecture	
step	by	step
@PreusslerBerlin
Untestable	code
is	bad	code!
@PreusslerBerlin
If	you
see	crap,	
replace it!
@PreusslerBerlin
Add	testing	in	feature	planning
@PreusslerBerlin
Strict	Definition	of	Done
@PreusslerBerlin
YOU should	sign	
the	manifesto!
@PreusslerBerlin
manifesto.softwarecraftsmanship.org
Test	Driven	Development
@PreusslerBerlin
TDD is	fun
@PreusslerBerlin
Pair	programming	is	fun
@PreusslerBerlin
Ever	tried	the	“evil	coder”?
Testing	is	fun
@PreusslerBerlin
Playground	for	languages	and	libraries
Don‘t ship crap!
@PreusslerBerlin
Thank you!
@PreusslerBerlin
We are hiring!
careers.gsa@vimn.com

Más contenido relacionado

Destacado

Unit testing in android
Unit testing in androidUnit testing in android
Unit testing in android
Li-Wei Cheng
 

Destacado (20)

Testing for Android: When, Where, and How to Successfully Use Test Automation
Testing for Android: When, Where, and How to Successfully Use Test AutomationTesting for Android: When, Where, and How to Successfully Use Test Automation
Testing for Android: When, Where, and How to Successfully Use Test Automation
 
Unit Testing Android Applications
Unit Testing Android ApplicationsUnit Testing Android Applications
Unit Testing Android Applications
 
Testing Android Application, Droidcon Torino
Testing Android Application, Droidcon TorinoTesting Android Application, Droidcon Torino
Testing Android Application, Droidcon Torino
 
Android Testing: An Overview
Android Testing: An OverviewAndroid Testing: An Overview
Android Testing: An Overview
 
Android Building, Testing and reversing
Android Building, Testing and reversingAndroid Building, Testing and reversing
Android Building, Testing and reversing
 
Testing Android applications with Maveryx
Testing Android applications with MaveryxTesting Android applications with Maveryx
Testing Android applications with Maveryx
 
Inside Android Testing
Inside Android TestingInside Android Testing
Inside Android Testing
 
Testing Android
Testing AndroidTesting Android
Testing Android
 
Android Testing, Why So Hard?!
Android Testing, Why So Hard?!Android Testing, Why So Hard?!
Android Testing, Why So Hard?!
 
Android testing
Android testingAndroid testing
Android testing
 
Testing With Open Source
Testing With Open SourceTesting With Open Source
Testing With Open Source
 
Unit testing in android
Unit testing in androidUnit testing in android
Unit testing in android
 
Unit testing on Android (Droidcon Dubai 2015)
Unit testing on Android (Droidcon Dubai 2015)Unit testing on Android (Droidcon Dubai 2015)
Unit testing on Android (Droidcon Dubai 2015)
 
Unit testing and Android
Unit testing and AndroidUnit testing and Android
Unit testing and Android
 
Mobile Performance Testing - Best Practices
Mobile Performance Testing - Best PracticesMobile Performance Testing - Best Practices
Mobile Performance Testing - Best Practices
 
Rapid Android Application Security Testing
Rapid Android Application Security TestingRapid Android Application Security Testing
Rapid Android Application Security Testing
 
Oh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to MutationOh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to Mutation
 
Testing on Android
Testing on AndroidTesting on Android
Testing on Android
 
How ANDROID TESTING changed how we think about Death - Second Edition
How ANDROID TESTING changed how we think about Death - Second EditionHow ANDROID TESTING changed how we think about Death - Second Edition
How ANDROID TESTING changed how we think about Death - Second Edition
 
Performance Testing for Mobile Apps & Sites using Apache JMeter
Performance Testing for Mobile Apps & Sites using Apache JMeterPerformance Testing for Mobile Apps & Sites using Apache JMeter
Performance Testing for Mobile Apps & Sites using Apache JMeter
 

Similar a Unit Testing on Android: why and how? DevFest Romania, Bucharest 2016

Poster Drone Based Aerial Imaging for Post-Disaster Reconnaissance by Theau H...
Poster Drone Based Aerial Imaging for Post-Disaster Reconnaissance by Theau H...Poster Drone Based Aerial Imaging for Post-Disaster Reconnaissance by Theau H...
Poster Drone Based Aerial Imaging for Post-Disaster Reconnaissance by Theau H...
Theau Heral
 

Similar a Unit Testing on Android: why and how? DevFest Romania, Bucharest 2016 (20)

ResearchTalks Vol.6 - Flying robots in javascript
ResearchTalks Vol.6 - Flying robots in javascriptResearchTalks Vol.6 - Flying robots in javascript
ResearchTalks Vol.6 - Flying robots in javascript
 
The future of automated testing
The future of automated testingThe future of automated testing
The future of automated testing
 
用光達點雲秀3D
用光達點雲秀3D用光達點雲秀3D
用光達點雲秀3D
 
The Wonderful-Amazing-Orientation-Motion-Sensormatic Machine
The Wonderful-Amazing-Orientation-Motion-Sensormatic MachineThe Wonderful-Amazing-Orientation-Motion-Sensormatic Machine
The Wonderful-Amazing-Orientation-Motion-Sensormatic Machine
 
Google Wave: Ripple or Tsunami for Research
Google Wave: Ripple or Tsunami for ResearchGoogle Wave: Ripple or Tsunami for Research
Google Wave: Ripple or Tsunami for Research
 
NASA space apps guide for android
NASA space apps guide for androidNASA space apps guide for android
NASA space apps guide for android
 
SASTA UNREAL Science - using AR and VR
SASTA UNREAL Science - using AR and VRSASTA UNREAL Science - using AR and VR
SASTA UNREAL Science - using AR and VR
 
WebVR - JAX 2016
WebVR -  JAX 2016WebVR -  JAX 2016
WebVR - JAX 2016
 
Poster Drone Based Aerial Imaging for Post-Disaster Reconnaissance by Theau H...
Poster Drone Based Aerial Imaging for Post-Disaster Reconnaissance by Theau H...Poster Drone Based Aerial Imaging for Post-Disaster Reconnaissance by Theau H...
Poster Drone Based Aerial Imaging for Post-Disaster Reconnaissance by Theau H...
 
Semantics, Deep Learning, and the Transformation of Business
Semantics, Deep Learning, and the Transformation of BusinessSemantics, Deep Learning, and the Transformation of Business
Semantics, Deep Learning, and the Transformation of Business
 
Aijaz tango
Aijaz tangoAijaz tango
Aijaz tango
 
Fab Academy 2015: 3D Scanning
Fab Academy 2015: 3D ScanningFab Academy 2015: 3D Scanning
Fab Academy 2015: 3D Scanning
 
Augmented Reality with Project Tango - Droidcon 2016 Berlin
Augmented Reality with Project Tango - Droidcon 2016 BerlinAugmented Reality with Project Tango - Droidcon 2016 Berlin
Augmented Reality with Project Tango - Droidcon 2016 Berlin
 
MOOCEBAC
MOOCEBACMOOCEBAC
MOOCEBAC
 
cs498-1-1-CourseIntro.ppt
cs498-1-1-CourseIntro.pptcs498-1-1-CourseIntro.ppt
cs498-1-1-CourseIntro.ppt
 
Powerful tools that you need and might not know about
Powerful tools that you need and might not know aboutPowerful tools that you need and might not know about
Powerful tools that you need and might not know about
 
Python + NoSQL in Animations
Python + NoSQL in AnimationsPython + NoSQL in Animations
Python + NoSQL in Animations
 
PDS Imaging Node's Hosted Machine Learning Platform
PDS Imaging Node's Hosted Machine Learning PlatformPDS Imaging Node's Hosted Machine Learning Platform
PDS Imaging Node's Hosted Machine Learning Platform
 
Jared Finder (Google) Creating Mixed Reality Apps and Games with Project Tango
Jared Finder (Google) Creating Mixed Reality Apps and Games with Project TangoJared Finder (Google) Creating Mixed Reality Apps and Games with Project Tango
Jared Finder (Google) Creating Mixed Reality Apps and Games with Project Tango
 
Vr ar-overview-explanations
Vr ar-overview-explanationsVr ar-overview-explanations
Vr ar-overview-explanations
 

Más de Danny Preussler

Más de Danny Preussler (14)

We aint got no time - Droidcon Nairobi
We aint got no time - Droidcon NairobiWe aint got no time - Droidcon Nairobi
We aint got no time - Droidcon Nairobi
 
Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)Test Driven Development on Android (Kotlin Kenya)
Test Driven Development on Android (Kotlin Kenya)
 
TDD on android. Why and How? (Coding Serbia 2019)
TDD on android. Why and How? (Coding Serbia 2019)TDD on android. Why and How? (Coding Serbia 2019)
TDD on android. Why and How? (Coding Serbia 2019)
 
TDD on Android (Øredev 2018)
TDD on Android (Øredev 2018)TDD on Android (Øredev 2018)
TDD on Android (Øredev 2018)
 
Junit5: the next gen of testing, don't stay behind
Junit5: the next gen of testing, don't stay behindJunit5: the next gen of testing, don't stay behind
Junit5: the next gen of testing, don't stay behind
 
15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)
15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)
15 tips to improve your unit tests (Droidcon Berlin 2016 Barcamp)
 
All around the world, localization and internationalization on Android (Droid...
All around the world, localization and internationalization on Android (Droid...All around the world, localization and internationalization on Android (Droid...
All around the world, localization and internationalization on Android (Droid...
 
(Android) Developer Survival in Multiscreen World, MobCon Sofia 2016
(Android) Developer Survival in Multiscreen World, MobCon Sofia 2016(Android) Developer Survival in Multiscreen World, MobCon Sofia 2016
(Android) Developer Survival in Multiscreen World, MobCon Sofia 2016
 
More android code puzzles
More android code puzzlesMore android code puzzles
More android code puzzles
 
Bye Bye Charles, Welcome Odo, Android Meetup Berlin May 2014
Bye Bye Charles, Welcome Odo, Android Meetup Berlin May 2014Bye Bye Charles, Welcome Odo, Android Meetup Berlin May 2014
Bye Bye Charles, Welcome Odo, Android Meetup Berlin May 2014
 
Abgeschottete Realität - Testen im Emulator, Mobile Testing Days 2014, Berlin
Abgeschottete Realität - Testen im Emulator, Mobile Testing Days 2014, BerlinAbgeschottete Realität - Testen im Emulator, Mobile Testing Days 2014, Berlin
Abgeschottete Realität - Testen im Emulator, Mobile Testing Days 2014, Berlin
 
Rockstar Android Testing (Mobile TechCon Munich 2014)
Rockstar Android Testing (Mobile TechCon Munich 2014)Rockstar Android Testing (Mobile TechCon Munich 2014)
Rockstar Android Testing (Mobile TechCon Munich 2014)
 
Android Code Puzzles (DroidCon Amsterdam 2012)
Android Code Puzzles (DroidCon Amsterdam 2012)Android Code Puzzles (DroidCon Amsterdam 2012)
Android Code Puzzles (DroidCon Amsterdam 2012)
 
Android Unit Testing With Robolectric
Android Unit Testing With RobolectricAndroid Unit Testing With Robolectric
Android Unit Testing With Robolectric
 

Último

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

Unit Testing on Android: why and how? DevFest Romania, Bucharest 2016