Local unit tests run on the JVM, while instrumented unit tests run on an Android device or emulator. Local tests are faster and don’t require Android dependencies, making them suitable for testing pure Java code like business logic and data processing. Instrumented tests are used when testing components that rely on the Android framework, such as UI interactions and database operations.
Use local unit tests for:
1. Testing non-Android dependent code
2. Faster execution
Use instrumented unit tests for:
1. Testing Android-dependent components
2. Validating UI behavior
3. Assessing performance on real devices/emulators