forked from square/dagger
-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Description
Given a class
@AndroidEntryPoint
MyActivity : AppCompatActivity()
and a test class
@HiltAndroidTest
@RunWith(RobolectricTestRunner::class)
@LooperMode(LooperMode.Mode.PAUSED)
class MyActivityTest() {
private lateinit var scenario : ActivityScenario<MainActivity>
@Rule
@JvmField
val rule : HiltAndroidRule = HiltAndroidRule(this)
@Before
fun setup() {
rule.inject()
scenario = ActivityScenario.launch(MyActivity::class.java)
}
@Test
fun myActivityTest() {
scenario.onActivity { activity: MyActivity ->
// test code
}
}
// .. rest of test class
}
and given JaCoCo Gradle Plugin version 0.8.5
Expected: Some code coverage on MyActivity class.
Actual:: 0% coverage
Notes:
- The coverage worked fine before the hilt plugin migration
- Given the same scenario with
@AndroidEntryPoint MyActivity : MyActivityBase()whereclass ÀctivityBase : AppCompatActivity()There is coverage reported onActivityBasebut not onMyActivity.
This is surely to do with the fact that Hilt is adding an injecting class between MyActivity and it's super class.
This is a Generic example, please tag me if you require any more information.
DamienDennehy, suwiringSIxbert, hoop208, alixwar and cac-ritaslott