Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActivityTestRule is deprecated on android test

This is a scope of my instrumented test:

...
import androidx.test.rule.ActivityTestRule

@RunWith(AndroidJUnit4::class)
@LargeTest
class InstrumentDialogFragmentTest {

    @get:Rule
    val activityRule = ActivityTestRule(MainActivity::class.java)
}

My gradle:

androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test:rules:1.4.0'

I'm getting this warning:

'ActivityTestRule<T : Activity!>' is deprecated. Deprecated in Java
like image 998
Pierre Vieira Avatar asked Feb 12 '26 21:02

Pierre Vieira


1 Answers

You can still use it on 'androidx.test:rules:1.2.0'. It is deprecated on 1.4.0. Use ActivityScenario or ActivityScenarioRule instead.

Learn more about ActivityTestRule: developer.android

like image 168
Hasan Çobanoğlu Avatar answered Feb 15 '26 11:02

Hasan Çobanoğlu