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.
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.
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 .
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.
If your application flow is HomeActivity after Login Activity then you will not be able to launch HomeActvity first
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With