What problem does it solve?
This skill fixes common Android/JVM test setup failures caused by importing the wrong AndroidJUnit4 and InstrumentationRegistry classes, missing test-size filtering, or forgetting the required coroutine Main dispatcher wiring.
Core Features & Use Cases
- Canonical AndroidJUnit4 runner selection: Use the non-deprecated
androidx.test.ext.junit.runners.AndroidJUnit4 so Android framework plumbing works correctly.
- Correct registries and Context access: Import
androidx.test.platform.app.InstrumentationRegistry and use androidx.test.core.app.ApplicationProvider.getApplicationContext() instead of deprecated registry APIs.
- Test-size filtering and Truth subjects: Apply
@SmallTest / @MediumTest / @LargeTest (wired to runner -e size) and use Android-aware Truth subjects from androidx.test.ext:truth.
- Main dispatcher test rule: Install a
MainDispatcherRule pattern so Dispatchers.Main consumers (e.g., viewModelScope, LaunchedEffect) don’t crash on the JVM.
Quick Start
Ask an AI coding agent to configure your Android module’s src/test JUnit4 dependencies, runner annotation, InstrumentationRegistry and ApplicationProvider imports, and add MainDispatcherRule plus @SmallTest/@MediumTest/@LargeTest so your tests run and can be filtered by size.