TestinginAndroid
SohamMondalFounder,Triveous
About me
- Founder,Triveous- Creator,VoiceRecorder- GoogleExpert:UX- Android/UXconsultant- OrganizeratBlrdroid- MentorattheGoogleLaunchpadAccelerator
Agenda
• Androidarchitecture:MVP/MVVM/MVC?• WhatisTesting?Testingprinciples• TypesofTests• Unittesting• Demo:UnitTesting• InstrumentationTesting• Demo:Instrumentationtesting• ContinuousIntegration
Android Architecture
• MVC:ModelViewController• MVP:ModelViewPresenter• MVVM:ModelViewViewModel• CleanArchitecturebyUncleBob
Clean Architecture
• Framework• SlavesoftheFramework• SeparatebusinesslogicfromFramework• Activities/Fragments• Entanglement• ImpactsPortability/Maintainability/Clarityofthesolution
MVP
• Presenter• InjectingpresenterintoViews
• Canunittestthepresenter
http://hannesdorfmann.com/mosby/mvp/
TESTINGTestinghelpscreategreat,stable,maintainableandscalableapps
Testing Principles
• Cleanarchitecture• Understandwhatyou’retryingtotest• Isolation• Integration• Allpossiblescenarios• TDD
Type of Tests
• Unittests• Integrationtests• Endtoendtests(Instrumentationtests)
http://googletesting.blogspot.in/2015/04/just-say-no-to-more-end-to-end-tests.html
Objective of Unit Testing?
• Justthecorefunctionality/business logic• Noexternaldependencies• Quickandpredictable• Allpossiblescenarios• TDD
Unit Testing
• Options:Roboelectric,JUnit• Unittestingonandroidstudio• Mockito• PowerMock
Mockito
-@mock-when/thenReturn-@spy-verify-@ArgumentCaptor
UNITTESTDEMO
Objective:Whatareyoutesting?
• Endtoendfunctionality• UI• Externaldependencies• Longer• Flaky
Instrumentation tests
• Options:Robotium,Espresso• Whyisespressogenerallybetter?• Espressotestrecorderinandroidstudio• Supportforfirebasetestlab
ESPRESSODEMO
More Espresso
• Espresso-IntentsandIntentStubbing• Espresso-ContribforDatePicker,RecyclerView,Draweractions,Accessibilitychecks,CountingIdlingResource
• Idlingresources• Codecoverage
CONTINUOUSINTEGRATION
CI
• Jenkins• Travis/CircleCI/others• Integrationwithgithubandothers• Automatedreporting:Email/Updateslack• Deploytoplaystore