简体   繁体   中英

Why last added activityTest class launched firstly

I am trying to launch activity from Splash activity-->Main activity... 1)created splashactivityTest 2)created mainActivirtTest

when testing started it launched from mainActivity ie:last added activity.why?

Android Manifest

        <activity
            android:name=".SplashActivity">

            <!-- move this code to the activity you want to launch first -->
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <!-- move this code to the activity you want to launch first -->

        </activity>

        <activity
            android:name=".MainActivity">

        </activity>

Using ActivityTestRule you can specify the activity that you would like to test.

Adding the following code in your test class:

@get:Rule
var activityRule: ActivityTestRule<MainActivity>
       = ActivityTestRule(MainActivity::class.java)

Should specify the activity that you would like to use for testing. See Use Espresso with ActivityTestRule for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM