1. Add dependency in your Gradle file.
2. Annotate the test with @HiltAndroidTest
3. Add test rule(HiltAndroidRule), like @get: Rule
var hiltRule = HiltAndroidRule(this)
and inject this hilt rule in any method or in setup() function like hiltRule.Inject()
important: If your test uses multiple test rule make sure HiltAndroidRule runs before any other test rule. (you can also mange this using order)
4. Create your own runner class extending AndroidJUnitRunner() and override the method newApplication(...) and pass HiltTestApplication::class.java.name & specify your package name inside testInstrumentation runner dependency.
5. At last, we need to use Test dependency like fake or mock and we need to un-install production module & add testFake module.
Video Url = https: