SlideShare a Scribd company logo
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?
Unit Testing on Android: why and how? DevFest Romania, Bucharest 2016
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

More Related Content

PDF
Clean code on Android (Droidcon Dubai 2015)
PDF
Getting Started in VR with JS
PDF
Gradle dependency management when multi module
PDF
WebVR - MobileTechCon Berlin 2016
PPTX
Unit testing without Robolectric, Droidcon Berlin 2016
PPTX
Demystifying dependency Injection: Dagger and Toothpick
PDF
Introduction to android testing - oscon 2012
PPTX
Android Performance Tips & Tricks
Clean code on Android (Droidcon Dubai 2015)
Getting Started in VR with JS
Gradle dependency management when multi module
WebVR - MobileTechCon Berlin 2016
Unit testing without Robolectric, Droidcon Berlin 2016
Demystifying dependency Injection: Dagger and Toothpick
Introduction to android testing - oscon 2012
Android Performance Tips & Tricks

Viewers also liked (20)

PPTX
Testing for Android: When, Where, and How to Successfully Use Test Automation
PPTX
Unit Testing Android Applications
PPTX
Testing Android Application, Droidcon Torino
PDF
Android Testing: An Overview
PDF
Android Building, Testing and reversing
PDF
Testing Android applications with Maveryx
PDF
Inside Android Testing
PDF
Testing Android
PDF
Android Testing, Why So Hard?!
PDF
Android testing
PDF
Testing With Open Source
PDF
Unit testing in android
PDF
Unit testing on Android (Droidcon Dubai 2015)
PDF
Unit testing and Android
PDF
Mobile Performance Testing - Best Practices
PPTX
Rapid Android Application Security Testing
PDF
Oh so you test? - A guide to testing on Android from Unit to Mutation
PDF
Testing on Android
PDF
How ANDROID TESTING changed how we think about Death - Second Edition
PDF
Performance Testing for Mobile Apps & Sites using Apache JMeter
Testing for Android: When, Where, and How to Successfully Use Test Automation
Unit Testing Android Applications
Testing Android Application, Droidcon Torino
Android Testing: An Overview
Android Building, Testing and reversing
Testing Android applications with Maveryx
Inside Android Testing
Testing Android
Android Testing, Why So Hard?!
Android testing
Testing With Open Source
Unit testing in android
Unit testing on Android (Droidcon Dubai 2015)
Unit testing and Android
Mobile Performance Testing - Best Practices
Rapid Android Application Security Testing
Oh so you test? - A guide to testing on Android from Unit to Mutation
Testing on Android
How ANDROID TESTING changed how we think about Death - Second Edition
Performance Testing for Mobile Apps & Sites using Apache JMeter
Ad

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

PDF
Android testing part i
PPTX
Unit Testing in Android
PDF
Unit testing (Exploring the other side as a tester)
PDF
Mobile Development - Unit and Automation Testing
PDF
Do you have a #bug? Your unit tests are not well planned
PPTX
Dev fest2015androidunittestingbyoyewaleademolasao
PPS
Unit Testing
PDF
Unit testing, principles
PPT
Agile latvia evening_unit_testing_in_practice
PPTX
2016 10-04: tdd++: tdd made easier
PDF
What is Unit Testing? - A Comprehensive Guide
PDF
What Is Unit Testing A Complete Guide With Examples.pdf
PPTX
Traversing the Test Pyramid for Android Development
PDF
Clean Unit Tests
PDF
What Is Unit Testing_ A Complete Guide With Examples.pdf
PDF
Unit Testing Guide. Helps to understand the basics of unit testing .
PPTX
Unit tests 101
PDF
Introduction To UnitTesting & JUnit
PDF
Android TDD
PPS
Why Unit Testingl
Android testing part i
Unit Testing in Android
Unit testing (Exploring the other side as a tester)
Mobile Development - Unit and Automation Testing
Do you have a #bug? Your unit tests are not well planned
Dev fest2015androidunittestingbyoyewaleademolasao
Unit Testing
Unit testing, principles
Agile latvia evening_unit_testing_in_practice
2016 10-04: tdd++: tdd made easier
What is Unit Testing? - A Comprehensive Guide
What Is Unit Testing A Complete Guide With Examples.pdf
Traversing the Test Pyramid for Android Development
Clean Unit Tests
What Is Unit Testing_ A Complete Guide With Examples.pdf
Unit Testing Guide. Helps to understand the basics of unit testing .
Unit tests 101
Introduction To UnitTesting & JUnit
Android TDD
Why Unit Testingl
Ad

More from Danny Preussler (14)

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

Recently uploaded (20)

PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Spectroscopy.pptx food analysis technology
PDF
Encapsulation theory and applications.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPT
Teaching material agriculture food technology
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
MIND Revenue Release Quarter 2 2025 Press Release
Spectroscopy.pptx food analysis technology
Encapsulation theory and applications.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Encapsulation_ Review paper, used for researhc scholars
Dropbox Q2 2025 Financial Results & Investor Presentation
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Advanced methodologies resolving dimensionality complications for autism neur...
20250228 LYD VKU AI Blended-Learning.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
MYSQL Presentation for SQL database connectivity
Review of recent advances in non-invasive hemoglobin estimation
“AI and Expert System Decision Support & Business Intelligence Systems”
Reach Out and Touch Someone: Haptics and Empathic Computing
Teaching material agriculture food technology
The Rise and Fall of 3GPP – Time for a Sabbatical?

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