powerful tools that help you test every aspect of your application at every level from unit to framework." In simple words: Run your app and interact with it, without touching your device/emulator.
s t r u m e n t a t i o n T e s t C a s e 2 < T > Launches new activity before each test Finishes the activity after each test g e t A c t i v i t y ( )
n s t r u m e n t a t i o n / > Loaded into the same process Instrumentation provides access to target's C o n t e x t Start activities Get resources Main thread Instrumentation provides access to target's main thread
u t L o c a l F i l e U s e r s A P I C l i e n t T e s t Hide network calls behind an interface (UsersAPIClient) One implementation uses local files Another implementation actually performs HTTP requests
k o u t L i s t U s e r s R e c y c l e r V i e w A d a p t e r T e s t - p a r t 1 Keep implementation simple Focus on testing the interface methods: g e t I t e m C o u n t ( ) o n C r e a t e V i e w H o l d e r ( ) o n B i n d V i e w H o l d e r ( )
k o u t L i s t U s e r s R e c y c l e r V i e w A d a p t e r T e s t - p a r t 2 Feed the adapter with data as part of the test. R e c y c l e r V i e w . A d a p t e r D a t a O b s e r v e r
k o u t L i s t U s e r s R e c y c l e r V i e w A d a p t e r T e s t - p a r t 3 I m a g e D o w n l o a d e r interface P i c a s s o I m a g e D o w n l o a d e r
k o u t G e t U s e r s L o a d e r T e s t Call l o a d I n B a c k g r o u n d ( ) directly to avoid difficult async testing T e s t a b l e U s e r s A P I C l i e n t - verify interaction with components
k o u t G e t U s e r s L o a d e r T e s t _ m o c k i t o Quick way to get T e s t a b l e * * * implementations Use version 1.9.5 & Add to s e t U p ( ) method: S y s t e m . s e t P r o p e r t y ( " d e x m a k e r . d e x c a c h e " , g e t C o n t e x t ( ) . g e t C a c h e D i r ( ) . g e t P a t h ( ) ) ; Mockito dexmaker
u t U s e r s L i s t A c t i v i t y R o b o t i u m T e s t UI interactions WebView / Mobile Web automation capabilities Slower than Espresso and less feature rich Robotium
k o u t L o c a l F i l e U s e r s A P I C l i e n t T e s t _ u n i t t e s t s Runs on the JVM -> no device is required Special version of Android (mockable-android-XX.jar) Useful for non-Android related code
u t L o c a l F i l e U s e r s A P I C l i e n t _ r o b o l e c t r i c g i t c h e c k o u t L i s t U s e r s R e c y c l e r V i e w A d a p t e r T e s t _ r o b o l e c t r i c Special "Android SDK", tailored to testing Runs on the JVM -> no device is required A Lot of gotchas & quirks!
u t H t t p U s e r s A P I C l i e n t T e s t Local HTTP Server, tailored to testing Can simulate different network behaviors HTTP codes (200, 404, 500, ...) Timeouts Throttling Delays