Unit test chạy trên JVM không cần Android dependency (nhanh, không cần thiết bị).
- Dùng cho ViewModel, Repository, và utility logic.
- Instrumentation test chạy trên thiết bị/emulator với đầy đủ Android framework (chậm, cần thiết bị).
- Dùng cho Activity, Fragment, và UI behavior.
- Theo testing pyramid: 70% unit test, 20% integration, 10% UI test.
- Tool: JUnit + Mockito cho unit, Espresso/Compose Testing cho UI.
Unit tests run on the JVM without Android dependencies (fast, no device needed).
- Use for ViewModel, Repository, and utility logic.
- Instrumentation tests run on devices/emulators with full Android framework access (slow, need device).
- Use for Activities, Fragments, and UI behavior.
- Follow the testing pyramid: 70% unit tests, 20% integration, 10% UI tests.