Well, I wrote a testing code for checking to open new activity while a button click. My code is looks like
@Test
public void checkNewActivity() {
onView(withId(R.id.button_open_new_activity)).perform(click());
onView(withText("SecondActivity")).check(matches(isDisplayed()));
}
I also declared in both activity in the manifest.
<activity
android:name=".SecondActivity"
android:label="@string/title_activity_second"
android:theme="@style/AppTheme.NoActionBar">
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
But faced error in build the test file. Error
Android resource linking failed /Users/shihab/StudioProjects/AndroidTesting/app/build/intermediates/merged_manifests/debugAndroidTest/AndroidManifest.xml:9: error: attribute 'android:name' in tag must be a valid Java class name.
Aucun commentaire:
Enregistrer un commentaire