One test suite for instrumentation and Robolectric tests
summary
Claim: one test suite runs on device/emulator and on the JVM using Robolectric. Concrete tools and steps: copy or share tests via a shared test folder, add Robolectric and testImplementation deps, use Gradle tasks (connectedAndroidTest vs testDebugUnitTest), and implement environment-specific helpers like an airplane mode toggler (UIAutomator on device, Settings shadow + broadcast on Robolectric). Built a Robolectric shadow activity to launch secondary screens; it works but needs manual cleanup and IDE workarounds. Speed wins: examples show ~1 minute on Robolectric versus ~3+ minutes on emulators and orchestrator sometimes inflates runs toward an hour.
AI-written summary · about
chapters (10)
- 0:00Unified testing approach
- 3:16Device test execution lifecycle
- 6:48Robolectric overview and benefits
- 9:18Robolectric history and evolution
- 11:22Running Robolectric tests
- 13:48Shared test folder challenges
- 16:38Multi-activity testing
- 24:05System interaction testing
- 31:13Device vs Robolectric tests
- 34:25Should you use Robolectric?
related talks
46mEfficient Android UI Testing
41mAndroid Testing Bootstrap
34mFrictionless Android testing: Write once, run everywhere
44mWhat makes good unit tests for Android apps
42mProduction Level Test Driven Development and What's new
35mTesting Firebase Android SDKs at Google
20mUnit testing on Android
41mUnit Test Your Code, Even Your UI!
