How to Really Test an Android Application
summary
Shows how to make legacy Android code testable by refactoring: wrap static calls (e.g., in a ProfileManager), convert singletons to instances, and replace deep inheritance with composition using small view-manager and messenger components so Activities handle only UI wiring and Presenters hold business logic. Demonstrates testing tools and techniques: Mockito (PowerMock only when unavoidable), Robolectric or instrumentation tests for state, JUnit parameterized tests and Rules, and Hamcrest/AssertJ for readable assertions, reporting increased coverage and better edge-case detection while noting some later brittle approaches.
AI-written summary · about
chapters (10)
- 0:00Android test strategy
- 4:21Static methods testing
- 10:41Singletons testable
- 12:04Inheritance to composition
- 17:42MVP model separation
- 22:45Readable unit tests
- 28:05Advanced testing tools
- 33:00Assertion visibility
- 39:26Maintainable test practices
- 40:07Conclusion
related talks
42mWorking Effectively with (Android) Legacy Code
37mWorking Effectively with Android Legacy Code
44mWhat makes good unit tests for Android apps
46mEfficient Android UI Testing
20mUnit testing on Android
42mTestable Android Architecture
44mEfficient testing UI Android apps by example
45mWhere do the Android tests belong?
