configuring-junit4-on-android
Installation
SKILL.md
Configuring JUnit4 on Android — The Right Runner, Registry, and Matrix
Almost every "test suite is misconfigured" report boils down to one of three root causes: the wrong AndroidJUnit4 is imported, the wrong InstrumentationRegistry is imported, or the size-annotation / dispatcher plumbing is missing. This skill encodes the exact Gradle matrix from androidx.test:core 1.7.0 onward, the canonical FQCNs, and the minimal MainDispatcherRule pattern that androidx itself ships in testutils-ktx.
When to use this skill
- The user reports
Cannot resolve symbol AndroidJUnit4,AndroidJUnit4 is deprecated, or asks "whichAndroidJUnit4should I import". - The user reports
IllegalStateException: No instrumentation registeredfromInstrumentationRegistry.getInstrumentation()in a unit test, or asks whyInstrumentationRegistryis crossed out. - The user wants Truth subjects (
IntentSubject,BundleSubject,LocationSubject,ParcelableSubject) but does not know which artifact ships them. - The user wants
am instrument -e size smallto filter tests and asks how to wire@SmallTest/@MediumTest/@LargeTest. - The user is writing a
ViewModel/ coroutine test and needs the canonicalMainDispatcherRuletemplate.