testing in android€¦ · android architecture • mvc: model view controller • mvp: model view...
TRANSCRIPT
![Page 1: testing in android€¦ · Android Architecture • MVC: Model View Controller • MVP: Model View Presenter • MVVM: Model View ViewModel • Clean Architecture by UncleBob](https://reader036.vdocuments.us/reader036/viewer/2022062402/5ec95e8a918cbb6baa0724fd/html5/thumbnails/1.jpg)
TestinginAndroid
SohamMondalFounder,Triveous
![Page 2: testing in android€¦ · Android Architecture • MVC: Model View Controller • MVP: Model View Presenter • MVVM: Model View ViewModel • Clean Architecture by UncleBob](https://reader036.vdocuments.us/reader036/viewer/2022062402/5ec95e8a918cbb6baa0724fd/html5/thumbnails/2.jpg)
About me
- Founder,Triveous- Creator,VoiceRecorder- GoogleExpert:UX- Android/UXconsultant- OrganizeratBlrdroid- MentorattheGoogleLaunchpadAccelerator
![Page 3: testing in android€¦ · Android Architecture • MVC: Model View Controller • MVP: Model View Presenter • MVVM: Model View ViewModel • Clean Architecture by UncleBob](https://reader036.vdocuments.us/reader036/viewer/2022062402/5ec95e8a918cbb6baa0724fd/html5/thumbnails/3.jpg)
Agenda
• Androidarchitecture:MVP/MVVM/MVC?• WhatisTesting?Testingprinciples• TypesofTests• Unittesting• Demo:UnitTesting• InstrumentationTesting• Demo:Instrumentationtesting• ContinuousIntegration
![Page 4: testing in android€¦ · Android Architecture • MVC: Model View Controller • MVP: Model View Presenter • MVVM: Model View ViewModel • Clean Architecture by UncleBob](https://reader036.vdocuments.us/reader036/viewer/2022062402/5ec95e8a918cbb6baa0724fd/html5/thumbnails/4.jpg)
Android Architecture
• MVC:ModelViewController• MVP:ModelViewPresenter• MVVM:ModelViewViewModel• CleanArchitecturebyUncleBob
![Page 5: testing in android€¦ · Android Architecture • MVC: Model View Controller • MVP: Model View Presenter • MVVM: Model View ViewModel • Clean Architecture by UncleBob](https://reader036.vdocuments.us/reader036/viewer/2022062402/5ec95e8a918cbb6baa0724fd/html5/thumbnails/5.jpg)
Clean Architecture
• Framework• SlavesoftheFramework• SeparatebusinesslogicfromFramework• Activities/Fragments• Entanglement• ImpactsPortability/Maintainability/Clarityofthesolution
![Page 6: testing in android€¦ · Android Architecture • MVC: Model View Controller • MVP: Model View Presenter • MVVM: Model View ViewModel • Clean Architecture by UncleBob](https://reader036.vdocuments.us/reader036/viewer/2022062402/5ec95e8a918cbb6baa0724fd/html5/thumbnails/6.jpg)
MVP
• Presenter• InjectingpresenterintoViews
• Canunittestthepresenter
http://hannesdorfmann.com/mosby/mvp/
![Page 7: testing in android€¦ · Android Architecture • MVC: Model View Controller • MVP: Model View Presenter • MVVM: Model View ViewModel • Clean Architecture by UncleBob](https://reader036.vdocuments.us/reader036/viewer/2022062402/5ec95e8a918cbb6baa0724fd/html5/thumbnails/7.jpg)
TESTINGTestinghelpscreategreat,stable,maintainableandscalableapps
![Page 8: testing in android€¦ · Android Architecture • MVC: Model View Controller • MVP: Model View Presenter • MVVM: Model View ViewModel • Clean Architecture by UncleBob](https://reader036.vdocuments.us/reader036/viewer/2022062402/5ec95e8a918cbb6baa0724fd/html5/thumbnails/8.jpg)
Testing Principles
• Cleanarchitecture• Understandwhatyou’retryingtotest• Isolation• Integration• Allpossiblescenarios• TDD
![Page 9: testing in android€¦ · Android Architecture • MVC: Model View Controller • MVP: Model View Presenter • MVVM: Model View ViewModel • Clean Architecture by UncleBob](https://reader036.vdocuments.us/reader036/viewer/2022062402/5ec95e8a918cbb6baa0724fd/html5/thumbnails/9.jpg)
Type of Tests
• Unittests• Integrationtests• Endtoendtests(Instrumentationtests)
http://googletesting.blogspot.in/2015/04/just-say-no-to-more-end-to-end-tests.html
![Page 10: testing in android€¦ · Android Architecture • MVC: Model View Controller • MVP: Model View Presenter • MVVM: Model View ViewModel • Clean Architecture by UncleBob](https://reader036.vdocuments.us/reader036/viewer/2022062402/5ec95e8a918cbb6baa0724fd/html5/thumbnails/10.jpg)
Objective of Unit Testing?
• Justthecorefunctionality/business logic• Noexternaldependencies• Quickandpredictable• Allpossiblescenarios• TDD
![Page 11: testing in android€¦ · Android Architecture • MVC: Model View Controller • MVP: Model View Presenter • MVVM: Model View ViewModel • Clean Architecture by UncleBob](https://reader036.vdocuments.us/reader036/viewer/2022062402/5ec95e8a918cbb6baa0724fd/html5/thumbnails/11.jpg)
Unit Testing
• Options:Roboelectric,JUnit• Unittestingonandroidstudio• Mockito• PowerMock
![Page 12: testing in android€¦ · Android Architecture • MVC: Model View Controller • MVP: Model View Presenter • MVVM: Model View ViewModel • Clean Architecture by UncleBob](https://reader036.vdocuments.us/reader036/viewer/2022062402/5ec95e8a918cbb6baa0724fd/html5/thumbnails/12.jpg)
Mockito
-@mock-when/thenReturn-@spy-verify-@ArgumentCaptor
![Page 13: testing in android€¦ · Android Architecture • MVC: Model View Controller • MVP: Model View Presenter • MVVM: Model View ViewModel • Clean Architecture by UncleBob](https://reader036.vdocuments.us/reader036/viewer/2022062402/5ec95e8a918cbb6baa0724fd/html5/thumbnails/13.jpg)
UNITTESTDEMO
![Page 14: testing in android€¦ · Android Architecture • MVC: Model View Controller • MVP: Model View Presenter • MVVM: Model View ViewModel • Clean Architecture by UncleBob](https://reader036.vdocuments.us/reader036/viewer/2022062402/5ec95e8a918cbb6baa0724fd/html5/thumbnails/14.jpg)
Objective:Whatareyoutesting?
• Endtoendfunctionality• UI• Externaldependencies• Longer• Flaky
![Page 15: testing in android€¦ · Android Architecture • MVC: Model View Controller • MVP: Model View Presenter • MVVM: Model View ViewModel • Clean Architecture by UncleBob](https://reader036.vdocuments.us/reader036/viewer/2022062402/5ec95e8a918cbb6baa0724fd/html5/thumbnails/15.jpg)
Instrumentation tests
• Options:Robotium,Espresso• Whyisespressogenerallybetter?• Espressotestrecorderinandroidstudio• Supportforfirebasetestlab
![Page 16: testing in android€¦ · Android Architecture • MVC: Model View Controller • MVP: Model View Presenter • MVVM: Model View ViewModel • Clean Architecture by UncleBob](https://reader036.vdocuments.us/reader036/viewer/2022062402/5ec95e8a918cbb6baa0724fd/html5/thumbnails/16.jpg)
![Page 17: testing in android€¦ · Android Architecture • MVC: Model View Controller • MVP: Model View Presenter • MVVM: Model View ViewModel • Clean Architecture by UncleBob](https://reader036.vdocuments.us/reader036/viewer/2022062402/5ec95e8a918cbb6baa0724fd/html5/thumbnails/17.jpg)
![Page 18: testing in android€¦ · Android Architecture • MVC: Model View Controller • MVP: Model View Presenter • MVVM: Model View ViewModel • Clean Architecture by UncleBob](https://reader036.vdocuments.us/reader036/viewer/2022062402/5ec95e8a918cbb6baa0724fd/html5/thumbnails/18.jpg)
ESPRESSODEMO
![Page 19: testing in android€¦ · Android Architecture • MVC: Model View Controller • MVP: Model View Presenter • MVVM: Model View ViewModel • Clean Architecture by UncleBob](https://reader036.vdocuments.us/reader036/viewer/2022062402/5ec95e8a918cbb6baa0724fd/html5/thumbnails/19.jpg)
More Espresso
• Espresso-IntentsandIntentStubbing• Espresso-ContribforDatePicker,RecyclerView,Draweractions,Accessibilitychecks,CountingIdlingResource
• Idlingresources• Codecoverage
![Page 20: testing in android€¦ · Android Architecture • MVC: Model View Controller • MVP: Model View Presenter • MVVM: Model View ViewModel • Clean Architecture by UncleBob](https://reader036.vdocuments.us/reader036/viewer/2022062402/5ec95e8a918cbb6baa0724fd/html5/thumbnails/20.jpg)
CONTINUOUSINTEGRATION
![Page 21: testing in android€¦ · Android Architecture • MVC: Model View Controller • MVP: Model View Presenter • MVVM: Model View ViewModel • Clean Architecture by UncleBob](https://reader036.vdocuments.us/reader036/viewer/2022062402/5ec95e8a918cbb6baa0724fd/html5/thumbnails/21.jpg)
CI
• Jenkins• Travis/CircleCI/others• Integrationwithgithubandothers• Automatedreporting:Email/Updateslack• Deploytoplaystore
![Page 22: testing in android€¦ · Android Architecture • MVC: Model View Controller • MVP: Model View Presenter • MVVM: Model View ViewModel • Clean Architecture by UncleBob](https://reader036.vdocuments.us/reader036/viewer/2022062402/5ec95e8a918cbb6baa0724fd/html5/thumbnails/22.jpg)