jeudi 21 février 2019

Unresolved reference ActivityTestRule for AndroidX

I'm trying to test my UI via instrumentation test, with androidX espresso library. In my grade I have:

androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'

As specified in the documentation I'm attempting to import ActivityTestRule class in my test, however the reference is unresolved.

import androidx.test.filters.LargeTest
import androidx.test.runner.AndroidJUnit4
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
// unresolved reference here
import androidx.test.rule.ActivityTestRule
import it.zehus.mybike.ui.ride.RideActivity


/**
 * Instrumented test, which will execute on an Android device.
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
// deprecated here
@RunWith(AndroidJUnit4::class)
@LargeTest
class FragmentDashboardUiTest {
    @get:Rule // unresolved reference here
    val activityRule = ActivityTestRule(RideActivity::class.java)

    @Test
    fun myClassMethod_ReturnsTrue() {  }
}

Am I doing something wrong or there's a problem within AndroidX testing libraries?

Aucun commentaire:

Enregistrer un commentaire