SlideShare ist ein Scribd-Unternehmen logo
1 von 44
Downloaden Sie, um offline zu lesen
Unit	
  Tes)ng	
  on	
  Android	
  
Danny	
  Preussler	
  
GROUPON	
  
DroidCon	
  Dubai	
  
test	
  (c)	
  DaveBleasdale,	
  CC	
  by	
  2.0,	
  www.flickr.com/photos/sidelong/246816211	
  
Groupon	
  is	
  the	
  global	
  	
  
leader	
  in	
  local	
  commerce,	
  
making it easy for people around the world to search !
and discover great businesses at unbeatable prices.

Source: Internal data,, March 2014
WORLDWIDE!
260M+ subscribers 53.9M active customers 500+ markets 900M+ deals sold
2
$5B+ in annual billings 12,000+ global employees
Leading	
  the	
  way	
  in	
  mobile	
  commerce	
  
Our mobile app is available in 43 countries. 
Groupon’s vibrant mobile marketplace connects!
consumers with their local economy
3	
  
Sources: Internal Data; iTunes ranking for US stores available here - https://itunes.apple.com/WebObjects/
MZStore.woa/wa/viewFeature?id=500873243&mt=8&v0=www-itunes25Bcountdown-appstore 
Nearly 110 million people worldwide have
downloaded our mobile app at the end of Q4 2014.
One of the 25 most downloaded free
apps of all time
More than 50% of our Global transactions were
completed on a mobile device by the end of Q4
2014
About Me?
•  Groupon Berlin
•  Groupon Merchant App
•  Unit Test enthusiast
What	
  people	
  say	
  about	
  unit	
  tes0ng	
  
•  Slows	
  you	
  down	
  
•  I	
  know	
  my	
  code	
  
is	
  working!	
  
•  Only	
  have	
  UI	
  Code	
  
Day	
  27/365	
  -­‐	
  Imagina)on..	
  by	
  Caden	
  Crawford,	
  CC	
  by	
  2.0,	
  flickr.com/
photos/cadencrawford/8422302030	
  
What is a Unit Test?
•  Small	
  
Opposite	
  of	
  an	
  end-­‐to-­‐end-­‐test	
  
test	
  the	
  smallest	
  unit	
  possible	
  
•  You	
  should	
  have	
  LOTS	
  of	
  them	
  
•  Fast!!!!	
  
er	
  by	
  www.GlynLowe.com,	
  CC	
  by	
  2.0,	
  flickr.com/photos/glynlowe/10921728045	
  
Why	
  Unit	
  test? 	
  	
  
•  Documents	
  behaviour	
  
	
  
•  Refactoring	
  not	
  possible	
  	
  
without!	
  
	
  
•  Gives	
  trust	
  
	
  
•  Only	
  slows	
  down	
  	
  
if	
  you	
  don‘t	
  have	
  )me	
  	
  
for	
  quality	
  code	
  and	
  tes)ng	
  anyway	
  
Day	
  27/365	
  -­‐	
  Imagina)on..	
  by	
  Caden	
  Crawford,	
  CC	
  by	
  2.0,	
  	
  
flickr.com/photos/cadencrawford/8422302030	
  
Why	
  Unit	
  test? 	
  	
  
Code	
  without	
  Test	
  =	
  Legacy	
  code	
  
	
  
Only	
  Bad	
  Code	
  is	
  untestable!	
  
	
  
Day	
  27/365	
  -­‐	
  Imagina)on..	
  by	
  Caden	
  Crawford,	
  CC	
  by	
  2.0,	
  	
  
flickr.com/photos/cadencrawford/8422302030	
  
SOLID
FOUNDATIONFlughafen Berlin-Brandenburg, Blick in die Abflughalle by Muns CC BY 3.0
http://commons.wikimedia.org/wiki/File:120513-BER-innen.JPG
App development reality
Tidy garage by Bryn Pinzgauer CC 2.0
http://www.flickr.com/photos/12394349@N06/4492572621/in/photostream/
Pure JUnit?
java.lang.RuntimeException: Stub!
Android Firewall by Uncalno, CC BY 2.0 flickr.com/photos/uncalno/8538679708
Robolectric
New Android Unit Testing
Lost	
  Horizons	
  -­‐	
  Light	
  by	
  Simon	
  &	
  His	
  Camera,	
  CC	
  by	
  2.0	
  flickr.com/ph
New Android Unit Testing	
  
•  still experimental
•  hdp://tools.android.com/tech-­‐docs/unit-­‐tes)ng-­‐support	
  
•  Project	
  structure:	
  
	
  	
  	
  	
  src/main/java/Foo.java	
  
	
  	
  	
  	
  src/test/java/FooTest.java
•  gradle:	
  
android {
testOptions {
	
   	
   unitTests.returnDefaultValues = true
}
Lost	
  Horizons	
  -­‐	
  Light	
  by	
  Simon	
  &	
  His	
  Camera,	
  CC	
  by	
  2.0	
  flickr.com/photos/simon__syon/14842606832	
  
What	
  to	
  test?	
  
Start	
  your	
  engine	
  by	
  Norlando	
  Pobre,	
  CC	
  by	
  2.0,	
  flickr.com/photos/npobre/2601582256	
  
Great Wall of China (IV) by isawnyu. CC 2.0 http://
www.flickr.com/photos/isawnyu/7183821643/in/photostream/
Separate Java and Android Code?
Great Wall of China (IV) by isawnyu. CC 2.0 http://
www.flickr.com/photos/isawnyu/7183821643/in/photostream/
Separate Java and Android Code?
Android is not Java+UI
Intent, Bundle, SparseArray, Uri.. not fancy device classes!
You will never reuse this on another Java platform,
stop pretending!
Context everywhere
Recreate the System? (interface UI {...} ?)
You	
  can	
  test	
  everything!	
  
Typing	
  the	
  universe	
  by	
  Feliciano	
  Guimarães,	
  CC	
  by	
  2.0,	
  flickr.com/photos/jsome1/6097841770	
  
„Mock“???	
  
Martin Fowler:
„test-doubles ... pre-programmed with
expectations “
Typing	
  the	
  universe	
  by	
  Feliciano	
  Guimarães,	
  CC	
  by	
  2.0,	
  flickr.com/photos/jsome1/6097841770	
  
Typing	
  the	
  universe	
  by	
  Feliciano	
  Guimarães,	
  CC	
  by	
  2.0,	
  flickr.com/photos/jsome1/6097841770	
  
Mock	
  
TelephonyManager mgr =
mock(TelephonyManager.class);
when(mgr.getDeviceId())
.thenReturn("123456");
...
	
  
Spy	
  
MyPreferences pref =
spy(new MyPreferences(context));
…
verify(pref).saveTitle(same(title));
verify(pref).savePersonalData(anyString());
	
  
	
  
She	
  spy	
  by	
  Kangrex,	
  CC	
  by	
  2.0;	
  flickr.com/photos/kangrex/3012574701	
  
Building blocks of a Test	
  
public class AndroidAccountsTest {
AccountManager manager;
AndroidAccounts tested;	
  
@Before
public void setup() {...}
@Test
public void should_get_token() {
when(manager.peekAuthToken(....)).thenReturn("token");
String token = tested.getCurrentToken(...)
assertEquals("token", token);
}
}
swivel-­‐snot	
  by	
  Linus	
  Bohman,	
  CC	
  2.0,	
  flickr.com/photos/bohman/16062901379	
  
Easy...	
  
•  Test	
  u)lity	
  classes	
  
	
  
•  Test	
  JSON	
  parsing	
  
	
  
•  Test	
  API	
  layer	
  
	
  
Duplo	
  Pac-­‐Man	
  by	
  Dan	
  Diemer,	
  CC	
  by	
  2.0,	
  flickr.com/photos/diemer/192740446	
  
Gson gson = GsonFactory.getGson();
@Test
public void should_parse_json_data() {
String values = inputStreamToString(„auth.json"));
AuthRslt rslt = gson.fromJson(values, AuthRslt.class);
assertEquals("AQAAAABwgQ2vVzk-KjiEA3“,
result.getAccessToken());
}
Easy...	
  
Duplo	
  Pac-­‐Man	
  by	
  Dan	
  Diemer,	
  CC	
  by	
  2.0,	
  flickr.com/photos/diemer/192740446	
  
Easy	
  when	
  you	
  do	
  it	
  right	
  
•  Test	
  user	
  interac)on	
  (click	
  etc)	
  
•  Test	
  Fragments	
  and	
  Ac)vi)es	
  
	
  
Lego	
  small	
  car.	
  by	
  Do-­‐Hyun	
  Kim,	
  CC	
  by	
  2.0,	
  flickr.com/photos/s)ckkim/6805370739	
  
class NavFragment extends InjectedFragment {
Interactor interactor;
@OnClick(R.id.nav_button_checkout)
public void onClickCheckout() {
interactor.moveToCheckout(
getActivity());
}
}
User	
  interac)on	
  
Lego	
  small	
  car.	
  by	
  Do-­‐Hyun	
  Kim,	
  CC	
  by	
  2.0,	
  flickr.com/photos/s)ckkim/6805370739	
  
Test	
  for	
  this	
  is	
  trivial!	
  
Screen	
  changes	
  
@Test
public void should_do_transaction() {
TransactionUtil transactionsUtil =
mock(TransactionUtil.class),
tested.showPaymentMethods(
transactionsUtil, mock(Purchase.class));
verify(transactionsUtil)
.addAllowingStateLoss(
any(FragmentManager.class),
eq(android.R.id.content),
isA(PaymentFragment.class));
}
Lego	
  small	
  car.	
  by	
  Do-­‐Hyun	
  Kim,	
  CC	
  by	
  2.0,	
  flickr.com/photos/s)ckkim/6805370739	
  
Screen	
  changes	
  
Lego	
  small	
  car.	
  by	
  Do-­‐Hyun	
  Kim,	
  CC	
  by	
  2.0,	
  flickr.com/photos/s)ckkim/6805370739	
  
•  Robolectric	
  offers	
  FragmentTranscta)ons	
  and	
  
life	
  cycle	
  method:	
  
•  Robolectric
.buildActivity(
Activity.class)
.attach()
.create().....
•  Careful,	
  feature	
  flaky	
  
Screen	
  changes	
  
Lego	
  small	
  car.	
  by	
  Do-­‐Hyun	
  Kim,	
  CC	
  by	
  2.0,	
  flickr.com/photos/s)ckkim/6805370739	
  
•  Easier:	
  
Field field =
Fragment.class.getDeclaredField("mActivity");
field.setAccessible(true);
field.set(fragmentInstance, mock(Activity.class);
•  You	
  might	
  need	
  also	
  to	
  mock	
  getResources()
Harder	
  but	
  possible	
  
•  Test	
  UI	
  code	
  
	
  
LEGO	
  10179	
  Ul)mate	
  Collector's	
  Millenium	
  Falcon™	
  by	
  Do-­‐Hyun	
  Kim,	
  CC	
  by	
  2.0,	
  flickr.com/photos/s)ckkim/6966161598	
  
Test	
  UI	
  code	
  
public class BorderPainterTest {
Canvas canvas = mock(Canvas.class);
Circle circle = mock(Circle.class);
BorderPainter tested = new BorderPainter();
@Test
public void should_draw_two_circles() {
...
tested.drawBorder(new RectF(), canvas, circle);
InOrder inOrder = inOrder(canvas);
inOrder.verify(canvas).drawCircle(
anyFloat(), anyFloat(), eq(10f), any(Paint.class));
inOrder.verify(canvas).drawCircle(
anyFloat(), anyFloat(), eq(20f), any(Paint.class));
}
}
LEGO	
  10179	
  Ul)mate	
  Collector's	
  Millenium	
  Falcon™	
  by	
  Do-­‐Hyun	
  Kim,	
  CC	
  by	
  2.0,	
  flickr.com/photos/s)ckkim/6966161598	
  
Wri)ng	
  testable	
  code...	
  
•  Clean	
  Code	
  
•  Separa)on	
  	
  
of	
  Concerns	
  
Manual	
  Inside	
  by	
  Masked	
  Builder,	
  CC	
  by	
  2.0,	
  flickr.com/photos/masked-­‐builder/8517238602	
  
Dependency	
  Injec)on	
  helps	
  
•  Don‘t	
  create	
  dependencies	
  yourself	
  
•  Invert	
  Control!	
  
	
  
•  Inject	
  them!	
  
construct	
  by	
  Len	
  Madhews,	
  CC	
  by	
  2.0;	
  flickr.com/photos/mythoto/16412713709	
  
Syringe	
  with	
  Green	
  Liquid	
  by	
  Andres	
  Rueda,	
  CC	
  by	
  2.0;	
  lickr.com/photos/andresrueda/16558374828	
  
If	
  it‘s	
  hard	
  to	
  test...	
  
•  Class	
  is	
  too	
  large	
  
•  Class	
  is	
  doing	
  too	
  many	
  things	
  
•  Class	
  knows	
  too	
  many	
  things	
  
Modified	
  condi)on/decision	
  coverage	
  for	
  cri)cal	
  souware	
  tes)ng	
  by	
  Nguyen	
  Hung	
  Vu,	
  CC	
  by	
  2.0,	
  www.flickr.com/photos/vuhung/14621502361	
  
Make	
  it	
  fail!	
  
Apple	
  Mini	
  DisplayPort	
  adapter	
  FAIL	
  by	
  David	
  Joyce,	
  
CC	
  by	
  2.0,	
  flickr.com/photos/deapeajay/2969264395	
  
1	
  method	
  =	
  1	
  test?	
  
•  Test	
  all	
  cases,	
  else	
  you	
  might	
  miss	
  sth	
  
•  one	
  method	
  should	
  have	
  mul)ple	
  test	
  	
  
(although	
  coverage	
  already	
  reached	
  with	
  first)	
  
•  Don‘t	
  be	
  super	
  strict	
  on	
  units,	
  	
  
some)mes	
  end	
  to	
  end	
  might	
  make	
  sense	
  
i.e.	
  json	
  parsing	
  into	
  models	
  with	
  full	
  Json	
  
	
  
Coverage?	
  
• You	
  should	
  Measure	
  	
  
• Mo)vates!	
  
• Don‘t	
  trust	
  too	
  much	
  into	
  it	
  
When	
  to	
  use	
  Robolectric	
  
•  Parcel	
  Tests	
  
•  Arguments/Bundle	
  Tests	
  
•  Resource	
  loading	
  Tests	
  
Parcel	
  Tests	
  with	
  Robolectric	
  
@RunWith(RobolectricTestRunner.class)	
  
public	
  class	
  UserTest	
  {	
  
	
  	
  	
  	
  Parcel	
  parcel	
  =	
  Parcel.obtain();	
  
	
  	
  	
  	
  User	
  tested	
  =	
  new	
  User("123",	
  "456");	
  
	
  
	
  	
  	
  	
  @Test	
  
	
  	
  	
  	
  public	
  void	
  check_parcel_implementa)on()	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  tested.writeToParcel(parcel,	
  0);	
  
	
  	
  	
  	
  	
  	
  	
  	
  parcel.setDataPosi)on(0);	
  
	
  	
  	
  	
  	
  	
  	
  	
  User	
  out	
  =	
  User.CREATOR.createFromParcel(parcel);	
  
	
  	
  	
  	
  	
  	
  	
  	
  assertEquals("123",	
  out.getUser());	
  
	
  	
  	
  	
  	
  	
  	
  	
  assertEquals("456",	
  out.getPassword());	
  
	
  	
  	
  	
  }	
  
Resource	
  Tests	
  with	
  Robolectric	
  
@Test	
  
@Config(qualifiers	
  =	
  "en")	
  
public	
  void	
  getTotalAuerTaxLong()	
  {	
  
	
  	
  	
  	
  assertEquals(	
  
	
   	
  "$10.00	
  Due“,	
  
	
  	
  	
  	
  	
  	
  	
  tested.getTotalAuerTaxLong(1000));	
  
}	
  
	
  
Layout	
  tests	
  with	
  Robolectric	
  
@Test
public void checkPhoneNumberIsHidden() {
MyActivity activity = new MyActivity();
activity.onCreate();
TextView tv = (TextView)
activity.findViewById(R.id.callText);
assertEquals(View.GONE, tv.getVisibility());
}
Dead	
  End	
  -­‐	
  mid	
  by	
  bennylin0724,	
  CC	
  BY	
  2.0	
  
flickr.com/photos/benny_lin/191393604	
  
Test	
  all	
  the	
  Things!	
  
Start	
  your	
  engine	
  by	
  Norlando	
  Pobre,	
  CC	
  by	
  2.0,	
  flickr.com/photos/npobre/2601582256	
  
THANK	
  YOU	
  
Danny	
  Preussler	
  
GROUPON	
  	
  
Berlin	
  
	
  
dpreussler@groupon.com	
  	
  
github.com/groupon
engineering.groupon.com
Michael	
  Burton,	
  Roboguice	
  
Carlos	
  Sessa,	
  50	
  Android	
  hacks	
  
David	
  van	
  der	
  Bokke,	
  RoboRemote	
  
David	
  Willson,	
  Odo	
  
….	
  
Stephane	
  Nicolas,	
  RoboSpice	
  
Par)al	
  Supermen,	
  juliegomoll,	
  CC	
  by	
  2.0,	
  flickr.com/photos/juliegomoll/1352843346	
  

Weitere ähnliche Inhalte

Was ist angesagt?

Code to DI For - Dependency Injection for Modern Applications
Code to DI For - Dependency Injection for Modern ApplicationsCode to DI For - Dependency Injection for Modern Applications
Code to DI For - Dependency Injection for Modern ApplicationsCaleb Jenkins
 
Going native with less coupling: Dependency Injection in C++
Going native with less coupling: Dependency Injection in C++Going native with less coupling: Dependency Injection in C++
Going native with less coupling: Dependency Injection in C++Daniele Pallastrelli
 
Visual Component Testing -- w/ Gil Tayar (Applitools) and Gleb Bahmutov (Cyp...
Visual Component Testing  -- w/ Gil Tayar (Applitools) and Gleb Bahmutov (Cyp...Visual Component Testing  -- w/ Gil Tayar (Applitools) and Gleb Bahmutov (Cyp...
Visual Component Testing -- w/ Gil Tayar (Applitools) and Gleb Bahmutov (Cyp...Applitools
 
Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020Patricia Aas
 
Google Plus SignIn : l'Authentification Google
Google Plus SignIn : l'Authentification GoogleGoogle Plus SignIn : l'Authentification Google
Google Plus SignIn : l'Authentification GoogleMathias Seguy
 
Introductionandgreetings
IntroductionandgreetingsIntroductionandgreetings
IntroductionandgreetingsPozz ZaRat
 
README.MD for building the first purely digital mobile bank in Indonesia
README.MD for building the first purely digital mobile bank in Indonesia README.MD for building the first purely digital mobile bank in Indonesia
README.MD for building the first purely digital mobile bank in Indonesia Richard Radics
 
Google Play Services Rock
Google Play Services RockGoogle Play Services Rock
Google Play Services RockPeter Friese
 
Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...
Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...
Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...Shift Conference
 
Project Panama - Beyond the (JVM) Wall
Project Panama - Beyond the (JVM) WallProject Panama - Beyond the (JVM) Wall
Project Panama - Beyond the (JVM) WallChristoph Engelbert
 
Diving Deep with the Flex Component Life Cycle
Diving Deep with the Flex Component Life CycleDiving Deep with the Flex Component Life Cycle
Diving Deep with the Flex Component Life CycleEffective
 
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)Alina Vilk
 
Performance #6 threading
Performance #6  threadingPerformance #6  threading
Performance #6 threadingVitali Pekelis
 

Was ist angesagt? (17)

Code to DI For - Dependency Injection for Modern Applications
Code to DI For - Dependency Injection for Modern ApplicationsCode to DI For - Dependency Injection for Modern Applications
Code to DI For - Dependency Injection for Modern Applications
 
Going native with less coupling: Dependency Injection in C++
Going native with less coupling: Dependency Injection in C++Going native with less coupling: Dependency Injection in C++
Going native with less coupling: Dependency Injection in C++
 
Visual Component Testing -- w/ Gil Tayar (Applitools) and Gleb Bahmutov (Cyp...
Visual Component Testing  -- w/ Gil Tayar (Applitools) and Gleb Bahmutov (Cyp...Visual Component Testing  -- w/ Gil Tayar (Applitools) and Gleb Bahmutov (Cyp...
Visual Component Testing -- w/ Gil Tayar (Applitools) and Gleb Bahmutov (Cyp...
 
Device fragmentation vs clean code
Device fragmentation vs clean codeDevice fragmentation vs clean code
Device fragmentation vs clean code
 
Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020
 
Google Plus SignIn : l'Authentification Google
Google Plus SignIn : l'Authentification GoogleGoogle Plus SignIn : l'Authentification Google
Google Plus SignIn : l'Authentification Google
 
Introductionandgreetings
IntroductionandgreetingsIntroductionandgreetings
Introductionandgreetings
 
README.MD for building the first purely digital mobile bank in Indonesia
README.MD for building the first purely digital mobile bank in Indonesia README.MD for building the first purely digital mobile bank in Indonesia
README.MD for building the first purely digital mobile bank in Indonesia
 
Google Play Services Rock
Google Play Services RockGoogle Play Services Rock
Google Play Services Rock
 
Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...
Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...
Shift Remote: Mobile - Devops-ify your life with Github Actions - Nicola Cort...
 
JS and patterns
JS and patternsJS and patterns
JS and patterns
 
Project Panama - Beyond the (JVM) Wall
Project Panama - Beyond the (JVM) WallProject Panama - Beyond the (JVM) Wall
Project Panama - Beyond the (JVM) Wall
 
Side effects-con-redux
Side effects-con-reduxSide effects-con-redux
Side effects-con-redux
 
Your code are my tests
Your code are my testsYour code are my tests
Your code are my tests
 
Diving Deep with the Flex Component Life Cycle
Diving Deep with the Flex Component Life CycleDiving Deep with the Flex Component Life Cycle
Diving Deep with the Flex Component Life Cycle
 
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
 
Performance #6 threading
Performance #6  threadingPerformance #6  threading
Performance #6 threading
 

Andere mochten auch

Unit testing and Android
Unit testing and AndroidUnit testing and Android
Unit testing and AndroidTomáš Kypta
 
TDD with AngularJS
TDD with AngularJSTDD with AngularJS
TDD with AngularJSLeena N
 
Droid con 2013 workshop unit testing in android [robolectirc]
Droid con 2013 workshop   unit testing in android [robolectirc]Droid con 2013 workshop   unit testing in android [robolectirc]
Droid con 2013 workshop unit testing in android [robolectirc]Leena N
 
Robolectric Android Unit Testing Framework
Robolectric Android Unit Testing FrameworkRobolectric Android Unit Testing Framework
Robolectric Android Unit Testing Frameworktylerschultz
 
7 stages of unit testing
7 stages of unit testing7 stages of unit testing
7 stages of unit testingJorge Ortiz
 
Utilizando Espresso e UIAutomator no Teste de Apps Android
Utilizando Espresso e UIAutomator no Teste de Apps AndroidUtilizando Espresso e UIAutomator no Teste de Apps Android
Utilizando Espresso e UIAutomator no Teste de Apps AndroidEduardo Carrara de Araujo
 
Unit Testing Android Applications
Unit Testing Android ApplicationsUnit Testing Android Applications
Unit Testing Android ApplicationsRody Middelkoop
 
Android Performance Tips & Tricks
Android Performance Tips & TricksAndroid Performance Tips & Tricks
Android Performance Tips & TricksSergii Zhuk
 
Introduction to android testing - oscon 2012
Introduction to android testing - oscon 2012Introduction to android testing - oscon 2012
Introduction to android testing - oscon 2012OSCON Byrum
 
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 AutomationTrent Peterson
 
Tech Talk #5 : Android Automation Test with Espresso - Trần Văn Toàn
Tech Talk #5 : Android Automation Test with Espresso - Trần Văn ToànTech Talk #5 : Android Automation Test with Espresso - Trần Văn Toàn
Tech Talk #5 : Android Automation Test with Espresso - Trần Văn ToànNexus FrontierTech
 
Android Testing: An Overview
Android Testing: An OverviewAndroid Testing: An Overview
Android Testing: An OverviewSmartLogic
 
Testing Android Application, Droidcon Torino
Testing Android Application, Droidcon TorinoTesting Android Application, Droidcon Torino
Testing Android Application, Droidcon TorinoPietro Alberto Rossi
 
Android Performance Best Practices
Android Performance Best Practices Android Performance Best Practices
Android Performance Best Practices Amgad Muhammad
 
Testing Android applications with Maveryx
Testing Android applications with MaveryxTesting Android applications with Maveryx
Testing Android applications with MaveryxMaveryx
 
Unit Testing on Android: why and how? DevFest Romania, Bucharest 2016
Unit Testing on Android: why and how? DevFest Romania, Bucharest 2016Unit Testing on Android: why and how? DevFest Romania, Bucharest 2016
Unit Testing on Android: why and how? DevFest Romania, Bucharest 2016Danny Preussler
 
Inside Android Testing
Inside Android TestingInside Android Testing
Inside Android TestingFernando Cejas
 
Android Testing, Why So Hard?!
Android Testing, Why So Hard?!Android Testing, Why So Hard?!
Android Testing, Why So Hard?!Annyce Davis
 

Andere mochten auch (20)

Unit testing and Android
Unit testing and AndroidUnit testing and Android
Unit testing and Android
 
TDD with AngularJS
TDD with AngularJSTDD with AngularJS
TDD with AngularJS
 
Droid con 2013 workshop unit testing in android [robolectirc]
Droid con 2013 workshop   unit testing in android [robolectirc]Droid con 2013 workshop   unit testing in android [robolectirc]
Droid con 2013 workshop unit testing in android [robolectirc]
 
Robolectric Android Unit Testing Framework
Robolectric Android Unit Testing FrameworkRobolectric Android Unit Testing Framework
Robolectric Android Unit Testing Framework
 
7 stages of unit testing
7 stages of unit testing7 stages of unit testing
7 stages of unit testing
 
Utilizando Espresso e UIAutomator no Teste de Apps Android
Utilizando Espresso e UIAutomator no Teste de Apps AndroidUtilizando Espresso e UIAutomator no Teste de Apps Android
Utilizando Espresso e UIAutomator no Teste de Apps Android
 
Espresso Barista
Espresso BaristaEspresso Barista
Espresso Barista
 
Unit Testing Android Applications
Unit Testing Android ApplicationsUnit Testing Android Applications
Unit Testing Android Applications
 
Android Performance Tips & Tricks
Android Performance Tips & TricksAndroid Performance Tips & Tricks
Android Performance Tips & Tricks
 
Introduction to android testing - oscon 2012
Introduction to android testing - oscon 2012Introduction to android testing - oscon 2012
Introduction to android testing - oscon 2012
 
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
 
Tech Talk #5 : Android Automation Test with Espresso - Trần Văn Toàn
Tech Talk #5 : Android Automation Test with Espresso - Trần Văn ToànTech Talk #5 : Android Automation Test with Espresso - Trần Văn Toàn
Tech Talk #5 : Android Automation Test with Espresso - Trần Văn Toàn
 
Android Testing: An Overview
Android Testing: An OverviewAndroid Testing: An Overview
Android Testing: An Overview
 
Testing Android Application, Droidcon Torino
Testing Android Application, Droidcon TorinoTesting Android Application, Droidcon Torino
Testing Android Application, Droidcon Torino
 
Android Performance Best Practices
Android Performance Best Practices Android Performance Best Practices
Android Performance Best Practices
 
Testing Android applications with Maveryx
Testing Android applications with MaveryxTesting Android applications with Maveryx
Testing Android applications with Maveryx
 
Unit Testing on Android: why and how? DevFest Romania, Bucharest 2016
Unit Testing on Android: why and how? DevFest Romania, Bucharest 2016Unit Testing on Android: why and how? DevFest Romania, Bucharest 2016
Unit Testing on Android: why and how? DevFest Romania, Bucharest 2016
 
Inside Android Testing
Inside Android TestingInside Android Testing
Inside Android Testing
 
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
 

Ähnlich wie Unit Testing on Android - Essential Guide to Testing Your Android Apps

Making the Web Fireproof: A Building Code for Websites
Making the Web Fireproof: A Building Code for WebsitesMaking the Web Fireproof: A Building Code for Websites
Making the Web Fireproof: A Building Code for WebsitesDylan Wilbanks
 
2021 02 13 CodeGen Verona - Let’s code a drone to follow faces syncing everyt...
2021 02 13 CodeGen Verona - Let’s code a drone to follow faces syncing everyt...2021 02 13 CodeGen Verona - Let’s code a drone to follow faces syncing everyt...
2021 02 13 CodeGen Verona - Let’s code a drone to follow faces syncing everyt...Bruno Capuano
 
Hacking images on windows phone
Hacking images on windows phoneHacking images on windows phone
Hacking images on windows phoneRahat Anindo
 
COSCUP 2017 FACE OFF
COSCUP 2017 FACE OFFCOSCUP 2017 FACE OFF
COSCUP 2017 FACE OFFPRADA Hsiung
 
4 Node.js Gotchas: What your ops team needs to know
4 Node.js Gotchas: What your ops team needs to know4 Node.js Gotchas: What your ops team needs to know
4 Node.js Gotchas: What your ops team needs to knowDynatrace
 
MTC Spring 2013 - crossplatform woes - robert virkus - 2013-03-13
MTC Spring 2013 -  crossplatform woes - robert virkus - 2013-03-13MTC Spring 2013 -  crossplatform woes - robert virkus - 2013-03-13
MTC Spring 2013 - crossplatform woes - robert virkus - 2013-03-13Enough Software
 
【HITCON FreeTalk 2021 - SolarWinds 供應鏈攻擊事件分析】
【HITCON FreeTalk 2021 -  SolarWinds 供應鏈攻擊事件分析】【HITCON FreeTalk 2021 -  SolarWinds 供應鏈攻擊事件分析】
【HITCON FreeTalk 2021 - SolarWinds 供應鏈攻擊事件分析】Hacks in Taiwan (HITCON)
 
Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summi...
Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summi...Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summi...
Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summi...Constantine Mars
 
How I hacked the Google Daydream controller
How I hacked the Google Daydream controllerHow I hacked the Google Daydream controller
How I hacked the Google Daydream controllerMatteo Pisani
 
Call For Code: 시각인식을 활용한 피해상황 파악하기 by 맹개발
Call For Code: 시각인식을 활용한 피해상황 파악하기 by 맹개발Call For Code: 시각인식을 활용한 피해상황 파악하기 by 맹개발
Call For Code: 시각인식을 활용한 피해상황 파악하기 by 맹개발Yunho Maeng
 
Building Microservices in the cloud at AutoScout24
Building Microservices in the cloud at AutoScout24Building Microservices in the cloud at AutoScout24
Building Microservices in the cloud at AutoScout24Christian Deger
 
Android Wear: A Developer's Perspective
Android Wear: A Developer's PerspectiveAndroid Wear: A Developer's Perspective
Android Wear: A Developer's PerspectiveVin Lim
 
Automating Your Way out of the Dark Ages: Our Experience with (And Without) P...
Automating Your Way out of the Dark Ages: Our Experience with (And Without) P...Automating Your Way out of the Dark Ages: Our Experience with (And Without) P...
Automating Your Way out of the Dark Ages: Our Experience with (And Without) P...Burin Asavesna
 
Highway to heaven - XConf Manchester 2015
Highway to heaven - XConf Manchester 2015Highway to heaven - XConf Manchester 2015
Highway to heaven - XConf Manchester 2015Christian Deger
 
PyConZA 2019 Keynote - Deep Neural Networks for Video Applications
PyConZA 2019 Keynote - Deep Neural Networks for Video ApplicationsPyConZA 2019 Keynote - Deep Neural Networks for Video Applications
PyConZA 2019 Keynote - Deep Neural Networks for Video ApplicationsAlex Conway
 
The Truth About Your Web App's Performance
The Truth About Your Web App's PerformanceThe Truth About Your Web App's Performance
The Truth About Your Web App's PerformanceJohn Riviello
 
Breizhcamp Rennes 2011
Breizhcamp Rennes 2011Breizhcamp Rennes 2011
Breizhcamp Rennes 2011sekond0
 

Ähnlich wie Unit Testing on Android - Essential Guide to Testing Your Android Apps (20)

Making the Web Fireproof: A Building Code for Websites
Making the Web Fireproof: A Building Code for WebsitesMaking the Web Fireproof: A Building Code for Websites
Making the Web Fireproof: A Building Code for Websites
 
2021 02 13 CodeGen Verona - Let’s code a drone to follow faces syncing everyt...
2021 02 13 CodeGen Verona - Let’s code a drone to follow faces syncing everyt...2021 02 13 CodeGen Verona - Let’s code a drone to follow faces syncing everyt...
2021 02 13 CodeGen Verona - Let’s code a drone to follow faces syncing everyt...
 
Hacking images on windows phone
Hacking images on windows phoneHacking images on windows phone
Hacking images on windows phone
 
Cloud Spin - building a photo booth with the Google Cloud Platform
Cloud Spin - building a photo booth with the Google Cloud PlatformCloud Spin - building a photo booth with the Google Cloud Platform
Cloud Spin - building a photo booth with the Google Cloud Platform
 
tutorial
tutorialtutorial
tutorial
 
COSCUP 2017 FACE OFF
COSCUP 2017 FACE OFFCOSCUP 2017 FACE OFF
COSCUP 2017 FACE OFF
 
4 Node.js Gotchas: What your ops team needs to know
4 Node.js Gotchas: What your ops team needs to know4 Node.js Gotchas: What your ops team needs to know
4 Node.js Gotchas: What your ops team needs to know
 
MTC Spring 2013 - crossplatform woes - robert virkus - 2013-03-13
MTC Spring 2013 -  crossplatform woes - robert virkus - 2013-03-13MTC Spring 2013 -  crossplatform woes - robert virkus - 2013-03-13
MTC Spring 2013 - crossplatform woes - robert virkus - 2013-03-13
 
【HITCON FreeTalk 2021 - SolarWinds 供應鏈攻擊事件分析】
【HITCON FreeTalk 2021 -  SolarWinds 供應鏈攻擊事件分析】【HITCON FreeTalk 2021 -  SolarWinds 供應鏈攻擊事件分析】
【HITCON FreeTalk 2021 - SolarWinds 供應鏈攻擊事件分析】
 
Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summi...
Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summi...Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summi...
Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summi...
 
How I hacked the Google Daydream controller
How I hacked the Google Daydream controllerHow I hacked the Google Daydream controller
How I hacked the Google Daydream controller
 
Call For Code: 시각인식을 활용한 피해상황 파악하기 by 맹개발
Call For Code: 시각인식을 활용한 피해상황 파악하기 by 맹개발Call For Code: 시각인식을 활용한 피해상황 파악하기 by 맹개발
Call For Code: 시각인식을 활용한 피해상황 파악하기 by 맹개발
 
Building Microservices in the cloud at AutoScout24
Building Microservices in the cloud at AutoScout24Building Microservices in the cloud at AutoScout24
Building Microservices in the cloud at AutoScout24
 
Android Wear: A Developer's Perspective
Android Wear: A Developer's PerspectiveAndroid Wear: A Developer's Perspective
Android Wear: A Developer's Perspective
 
Coco
CocoCoco
Coco
 
Automating Your Way out of the Dark Ages: Our Experience with (And Without) P...
Automating Your Way out of the Dark Ages: Our Experience with (And Without) P...Automating Your Way out of the Dark Ages: Our Experience with (And Without) P...
Automating Your Way out of the Dark Ages: Our Experience with (And Without) P...
 
Highway to heaven - XConf Manchester 2015
Highway to heaven - XConf Manchester 2015Highway to heaven - XConf Manchester 2015
Highway to heaven - XConf Manchester 2015
 
PyConZA 2019 Keynote - Deep Neural Networks for Video Applications
PyConZA 2019 Keynote - Deep Neural Networks for Video ApplicationsPyConZA 2019 Keynote - Deep Neural Networks for Video Applications
PyConZA 2019 Keynote - Deep Neural Networks for Video Applications
 
The Truth About Your Web App's Performance
The Truth About Your Web App's PerformanceThe Truth About Your Web App's Performance
The Truth About Your Web App's Performance
 
Breizhcamp Rennes 2011
Breizhcamp Rennes 2011Breizhcamp Rennes 2011
Breizhcamp Rennes 2011
 

Mehr von Danny Preussler

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 NairobiDanny Preussler
 
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)Danny Preussler
 
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)Danny Preussler
 
TDD on Android (Øredev 2018)
TDD on Android (Øredev 2018)TDD on Android (Øredev 2018)
TDD on Android (Øredev 2018)Danny Preussler
 
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 behindDanny Preussler
 
Demystifying dependency Injection: Dagger and Toothpick
Demystifying dependency Injection: Dagger and ToothpickDemystifying dependency Injection: Dagger and Toothpick
Demystifying dependency Injection: Dagger and ToothpickDanny Preussler
 
Unit testing without Robolectric, Droidcon Berlin 2016
Unit testing without Robolectric, Droidcon Berlin 2016Unit testing without Robolectric, Droidcon Berlin 2016
Unit testing without Robolectric, Droidcon Berlin 2016Danny Preussler
 
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)Danny Preussler
 
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...Danny Preussler
 
(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 2016Danny Preussler
 
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, BerlinDanny Preussler
 
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)Danny Preussler
 
Android Code Puzzles (DroidCon Amsterdam 2012)
Android Code Puzzles (DroidCon Amsterdam 2012)Android Code Puzzles (DroidCon Amsterdam 2012)
Android Code Puzzles (DroidCon Amsterdam 2012)Danny Preussler
 

Mehr von Danny Preussler (13)

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
 
Demystifying dependency Injection: Dagger and Toothpick
Demystifying dependency Injection: Dagger and ToothpickDemystifying dependency Injection: Dagger and Toothpick
Demystifying dependency Injection: Dagger and Toothpick
 
Unit testing without Robolectric, Droidcon Berlin 2016
Unit testing without Robolectric, Droidcon Berlin 2016Unit testing without Robolectric, Droidcon Berlin 2016
Unit testing without Robolectric, Droidcon Berlin 2016
 
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
 
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)
 

Kürzlich hochgeladen

SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfRTS corp
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 

Kürzlich hochgeladen (20)

SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 

Unit Testing on Android - Essential Guide to Testing Your Android Apps

  • 1. Unit  Tes)ng  on  Android   Danny  Preussler   GROUPON   DroidCon  Dubai   test  (c)  DaveBleasdale,  CC  by  2.0,  www.flickr.com/photos/sidelong/246816211  
  • 2. Groupon  is  the  global     leader  in  local  commerce,   making it easy for people around the world to search ! and discover great businesses at unbeatable prices. Source: Internal data,, March 2014 WORLDWIDE! 260M+ subscribers 53.9M active customers 500+ markets 900M+ deals sold 2 $5B+ in annual billings 12,000+ global employees
  • 3. Leading  the  way  in  mobile  commerce   Our mobile app is available in 43 countries. Groupon’s vibrant mobile marketplace connects! consumers with their local economy 3   Sources: Internal Data; iTunes ranking for US stores available here - https://itunes.apple.com/WebObjects/ MZStore.woa/wa/viewFeature?id=500873243&mt=8&v0=www-itunes25Bcountdown-appstore Nearly 110 million people worldwide have downloaded our mobile app at the end of Q4 2014. One of the 25 most downloaded free apps of all time More than 50% of our Global transactions were completed on a mobile device by the end of Q4 2014
  • 4. About Me? •  Groupon Berlin •  Groupon Merchant App •  Unit Test enthusiast
  • 5. What  people  say  about  unit  tes0ng   •  Slows  you  down   •  I  know  my  code   is  working!   •  Only  have  UI  Code   Day  27/365  -­‐  Imagina)on..  by  Caden  Crawford,  CC  by  2.0,  flickr.com/ photos/cadencrawford/8422302030  
  • 6. What is a Unit Test? •  Small   Opposite  of  an  end-­‐to-­‐end-­‐test   test  the  smallest  unit  possible   •  You  should  have  LOTS  of  them   •  Fast!!!!   er  by  www.GlynLowe.com,  CC  by  2.0,  flickr.com/photos/glynlowe/10921728045  
  • 7. Why  Unit  test?     •  Documents  behaviour     •  Refactoring  not  possible     without!     •  Gives  trust     •  Only  slows  down     if  you  don‘t  have  )me     for  quality  code  and  tes)ng  anyway   Day  27/365  -­‐  Imagina)on..  by  Caden  Crawford,  CC  by  2.0,     flickr.com/photos/cadencrawford/8422302030  
  • 8. Why  Unit  test?     Code  without  Test  =  Legacy  code     Only  Bad  Code  is  untestable!     Day  27/365  -­‐  Imagina)on..  by  Caden  Crawford,  CC  by  2.0,     flickr.com/photos/cadencrawford/8422302030  
  • 9. SOLID FOUNDATIONFlughafen Berlin-Brandenburg, Blick in die Abflughalle by Muns CC BY 3.0 http://commons.wikimedia.org/wiki/File:120513-BER-innen.JPG
  • 10. App development reality Tidy garage by Bryn Pinzgauer CC 2.0 http://www.flickr.com/photos/12394349@N06/4492572621/in/photostream/
  • 11. Pure JUnit? java.lang.RuntimeException: Stub! Android Firewall by Uncalno, CC BY 2.0 flickr.com/photos/uncalno/8538679708
  • 12. Robolectric New Android Unit Testing Lost  Horizons  -­‐  Light  by  Simon  &  His  Camera,  CC  by  2.0  flickr.com/ph
  • 13. New Android Unit Testing   •  still experimental •  hdp://tools.android.com/tech-­‐docs/unit-­‐tes)ng-­‐support   •  Project  structure:          src/main/java/Foo.java          src/test/java/FooTest.java •  gradle:   android { testOptions {     unitTests.returnDefaultValues = true } Lost  Horizons  -­‐  Light  by  Simon  &  His  Camera,  CC  by  2.0  flickr.com/photos/simon__syon/14842606832  
  • 14. What  to  test?   Start  your  engine  by  Norlando  Pobre,  CC  by  2.0,  flickr.com/photos/npobre/2601582256  
  • 15. Great Wall of China (IV) by isawnyu. CC 2.0 http:// www.flickr.com/photos/isawnyu/7183821643/in/photostream/ Separate Java and Android Code?
  • 16. Great Wall of China (IV) by isawnyu. CC 2.0 http:// www.flickr.com/photos/isawnyu/7183821643/in/photostream/ Separate Java and Android Code? Android is not Java+UI Intent, Bundle, SparseArray, Uri.. not fancy device classes! You will never reuse this on another Java platform, stop pretending! Context everywhere Recreate the System? (interface UI {...} ?)
  • 17. You  can  test  everything!   Typing  the  universe  by  Feliciano  Guimarães,  CC  by  2.0,  flickr.com/photos/jsome1/6097841770  
  • 18. „Mock“???   Martin Fowler: „test-doubles ... pre-programmed with expectations “ Typing  the  universe  by  Feliciano  Guimarães,  CC  by  2.0,  flickr.com/photos/jsome1/6097841770  
  • 19. Typing  the  universe  by  Feliciano  Guimarães,  CC  by  2.0,  flickr.com/photos/jsome1/6097841770   Mock   TelephonyManager mgr = mock(TelephonyManager.class); when(mgr.getDeviceId()) .thenReturn("123456"); ...  
  • 20. Spy   MyPreferences pref = spy(new MyPreferences(context)); … verify(pref).saveTitle(same(title)); verify(pref).savePersonalData(anyString());     She  spy  by  Kangrex,  CC  by  2.0;  flickr.com/photos/kangrex/3012574701  
  • 21. Building blocks of a Test   public class AndroidAccountsTest { AccountManager manager; AndroidAccounts tested;   @Before public void setup() {...} @Test public void should_get_token() { when(manager.peekAuthToken(....)).thenReturn("token"); String token = tested.getCurrentToken(...) assertEquals("token", token); } } swivel-­‐snot  by  Linus  Bohman,  CC  2.0,  flickr.com/photos/bohman/16062901379  
  • 22. Easy...   •  Test  u)lity  classes     •  Test  JSON  parsing     •  Test  API  layer     Duplo  Pac-­‐Man  by  Dan  Diemer,  CC  by  2.0,  flickr.com/photos/diemer/192740446  
  • 23. Gson gson = GsonFactory.getGson(); @Test public void should_parse_json_data() { String values = inputStreamToString(„auth.json")); AuthRslt rslt = gson.fromJson(values, AuthRslt.class); assertEquals("AQAAAABwgQ2vVzk-KjiEA3“, result.getAccessToken()); } Easy...   Duplo  Pac-­‐Man  by  Dan  Diemer,  CC  by  2.0,  flickr.com/photos/diemer/192740446  
  • 24. Easy  when  you  do  it  right   •  Test  user  interac)on  (click  etc)   •  Test  Fragments  and  Ac)vi)es     Lego  small  car.  by  Do-­‐Hyun  Kim,  CC  by  2.0,  flickr.com/photos/s)ckkim/6805370739  
  • 25. class NavFragment extends InjectedFragment { Interactor interactor; @OnClick(R.id.nav_button_checkout) public void onClickCheckout() { interactor.moveToCheckout( getActivity()); } } User  interac)on   Lego  small  car.  by  Do-­‐Hyun  Kim,  CC  by  2.0,  flickr.com/photos/s)ckkim/6805370739   Test  for  this  is  trivial!  
  • 26. Screen  changes   @Test public void should_do_transaction() { TransactionUtil transactionsUtil = mock(TransactionUtil.class), tested.showPaymentMethods( transactionsUtil, mock(Purchase.class)); verify(transactionsUtil) .addAllowingStateLoss( any(FragmentManager.class), eq(android.R.id.content), isA(PaymentFragment.class)); } Lego  small  car.  by  Do-­‐Hyun  Kim,  CC  by  2.0,  flickr.com/photos/s)ckkim/6805370739  
  • 27. Screen  changes   Lego  small  car.  by  Do-­‐Hyun  Kim,  CC  by  2.0,  flickr.com/photos/s)ckkim/6805370739   •  Robolectric  offers  FragmentTranscta)ons  and   life  cycle  method:   •  Robolectric .buildActivity( Activity.class) .attach() .create()..... •  Careful,  feature  flaky  
  • 28. Screen  changes   Lego  small  car.  by  Do-­‐Hyun  Kim,  CC  by  2.0,  flickr.com/photos/s)ckkim/6805370739   •  Easier:   Field field = Fragment.class.getDeclaredField("mActivity"); field.setAccessible(true); field.set(fragmentInstance, mock(Activity.class); •  You  might  need  also  to  mock  getResources()
  • 29. Harder  but  possible   •  Test  UI  code     LEGO  10179  Ul)mate  Collector's  Millenium  Falcon™  by  Do-­‐Hyun  Kim,  CC  by  2.0,  flickr.com/photos/s)ckkim/6966161598  
  • 30. Test  UI  code   public class BorderPainterTest { Canvas canvas = mock(Canvas.class); Circle circle = mock(Circle.class); BorderPainter tested = new BorderPainter(); @Test public void should_draw_two_circles() { ... tested.drawBorder(new RectF(), canvas, circle); InOrder inOrder = inOrder(canvas); inOrder.verify(canvas).drawCircle( anyFloat(), anyFloat(), eq(10f), any(Paint.class)); inOrder.verify(canvas).drawCircle( anyFloat(), anyFloat(), eq(20f), any(Paint.class)); } } LEGO  10179  Ul)mate  Collector's  Millenium  Falcon™  by  Do-­‐Hyun  Kim,  CC  by  2.0,  flickr.com/photos/s)ckkim/6966161598  
  • 31. Wri)ng  testable  code...   •  Clean  Code   •  Separa)on     of  Concerns   Manual  Inside  by  Masked  Builder,  CC  by  2.0,  flickr.com/photos/masked-­‐builder/8517238602  
  • 32. Dependency  Injec)on  helps   •  Don‘t  create  dependencies  yourself   •  Invert  Control!     •  Inject  them!   construct  by  Len  Madhews,  CC  by  2.0;  flickr.com/photos/mythoto/16412713709   Syringe  with  Green  Liquid  by  Andres  Rueda,  CC  by  2.0;  lickr.com/photos/andresrueda/16558374828  
  • 33. If  it‘s  hard  to  test...   •  Class  is  too  large   •  Class  is  doing  too  many  things   •  Class  knows  too  many  things   Modified  condi)on/decision  coverage  for  cri)cal  souware  tes)ng  by  Nguyen  Hung  Vu,  CC  by  2.0,  www.flickr.com/photos/vuhung/14621502361  
  • 34. Make  it  fail!   Apple  Mini  DisplayPort  adapter  FAIL  by  David  Joyce,   CC  by  2.0,  flickr.com/photos/deapeajay/2969264395  
  • 35. 1  method  =  1  test?   •  Test  all  cases,  else  you  might  miss  sth   •  one  method  should  have  mul)ple  test     (although  coverage  already  reached  with  first)   •  Don‘t  be  super  strict  on  units,     some)mes  end  to  end  might  make  sense   i.e.  json  parsing  into  models  with  full  Json    
  • 36. Coverage?   • You  should  Measure     • Mo)vates!   • Don‘t  trust  too  much  into  it  
  • 37. When  to  use  Robolectric   •  Parcel  Tests   •  Arguments/Bundle  Tests   •  Resource  loading  Tests  
  • 38. Parcel  Tests  with  Robolectric   @RunWith(RobolectricTestRunner.class)   public  class  UserTest  {          Parcel  parcel  =  Parcel.obtain();          User  tested  =  new  User("123",  "456");            @Test          public  void  check_parcel_implementa)on()  {                  tested.writeToParcel(parcel,  0);                  parcel.setDataPosi)on(0);                  User  out  =  User.CREATOR.createFromParcel(parcel);                  assertEquals("123",  out.getUser());                  assertEquals("456",  out.getPassword());          }  
  • 39. Resource  Tests  with  Robolectric   @Test   @Config(qualifiers  =  "en")   public  void  getTotalAuerTaxLong()  {          assertEquals(      "$10.00  Due“,                tested.getTotalAuerTaxLong(1000));   }    
  • 40. Layout  tests  with  Robolectric   @Test public void checkPhoneNumberIsHidden() { MyActivity activity = new MyActivity(); activity.onCreate(); TextView tv = (TextView) activity.findViewById(R.id.callText); assertEquals(View.GONE, tv.getVisibility()); }
  • 41. Dead  End  -­‐  mid  by  bennylin0724,  CC  BY  2.0   flickr.com/photos/benny_lin/191393604  
  • 42. Test  all  the  Things!   Start  your  engine  by  Norlando  Pobre,  CC  by  2.0,  flickr.com/photos/npobre/2601582256  
  • 43. THANK  YOU   Danny  Preussler   GROUPON     Berlin     dpreussler@groupon.com    
  • 44. github.com/groupon engineering.groupon.com Michael  Burton,  Roboguice   Carlos  Sessa,  50  Android  hacks   David  van  der  Bokke,  RoboRemote   David  Willson,  Odo   ….   Stephane  Nicolas,  RoboSpice   Par)al  Supermen,  juliegomoll,  CC  by  2.0,  flickr.com/photos/juliegomoll/1352843346