Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to launch a particular Activity from Espresso Recorder?

I am using Espresso for my UI Testing. In Espresso, I can test any particular activity I want without having to go from the first activity with the following rule.

@Rule
public ActivityTestRule activityTestRule = new ActivityTestRule(HomeActivity.class);

Note: Here HomeActivity comes after LoginActivity.

But when I am using Espresso recorder, it always seems to begin the test from LoginActivity.I need to launch HomeActivity directly. So is there any option in Android Studio to launch a particular activity with Espresso Recorder.

like image 306
thedarkpassenger Avatar asked Sep 19 '16 12:09

thedarkpassenger


People also ask

How do you use an espresso test recorder?

Record UI interactions To start recording a test with Espresso Test Recorder, proceed as follows: Click Run > Record Espresso Test. In the Select Deployment Target window, choose the device on which you want to record the test. If necessary, create a new Android Virtual Device.

How do I get text from view in espresso?

The basic idea is to use a method with an internal ViewAction that retrieves the text in its perform method. Anonymous classes can only access final fields, so we cannot just let it set a local variable of getText() , but instead an array of String is used to get the string out of the ViewAction .


2 Answers

I just edit the manifest and set the activity I want to test as the first activity before running the test recorder.

    <activity android:name="ActivityToTest">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

And after recording the test of that activity I just restore the manifest.

Hope it helps.

like image 185
jeprubio Avatar answered Nov 15 '22 18:11

jeprubio


If your application flow is HomeActivity after Login Activity then you will not be able to launch HomeActvity first

like image 40
anuja jain Avatar answered Nov 15 '22 17:11

anuja jain