Skip to content

After integrating HiltRunner, it's always say 0 tests passed for instrumentation tests  #3223

@androidcodehunter

Description

@androidcodehunter

I am trying to write UI test using Hilt. When using androidx.test.runner.AndroidJUnitRunner tests always run with status passed or failed but when using mypackage.HiltTestRunner it's always 0 tests passed for any test cases under @HiltAndroidTest. Here is the class I am using to get the AndroidJUnitRunner,

class HiltTestRunner : AndroidJUnitRunner() {

    override fun newApplication(cl: ClassLoader?, name: String?, context: Context?): Application {
        return super.newApplication(cl, HiltTestApplication::class.java.name, context)
    }
}

I included the AndroidJUnitRunner in my gradle like this testInstrumentationRunner = "com.pinwheel.desktop.HiltTestRunner"

To check hilt test integration I am running a sample activity like this,

@HiltAndroidTest
class WarningActivityTest {

    @get:Rule(order = 0)
    var hiltRule = HiltAndroidRule(this)

    @Test
    fun check() {
        Timber.d("Testing running check")
        hiltRule.inject() 
        val scenario = launchActivity<WarningActivity>()
    }
}

Whatever I run it always say 0 tests passed. Here is the screenshoot from android studio bumblebeee,

warning test

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions