0
android私は2つのアクティビティ、MainActivityとDetailsActivityを持つサンプルアプリケーションを持っています。メインアクティビティにはリストとボタンがあり、それを押すと詳細アクティビティが開きます。その意図で、ArrayListとObjectを配置します。ボタンをクリックするとアクティビティが表示されることをどのようにテストできますか?
どのように動作するかテストできますか?エスプレッソそれは大丈夫ですか?
androidTestCompile 'com.android.support:support-annotations:25.3.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
@RunWith(AndroidJUnit4.class)
@LargeTest
public class FirstTest {
@Rule
public IntentsTestRule<MainActivity> mActivityRule = new IntentsTestRule<>(
MainActivity.class);
@Test
public void changeText_sameActivity() {
onView(withId(R.id.fab)).perform(click());
// How can i Specify the intent to the new Detail Activity?
intended(hasComponent(new ComponentName(getTargetContext(), InsectDetailsActivity.class)));
onView(withId(R.id.tv_original_title))
.check(matches(withText(/* The text depends on the Passing Intent*/)));
}
}
私はいくつかの編集を行います。 1つのインテントにマッチするWantedが見つかりました。実際に一致した0のインテント。そして、私はどのようにしてExtrasをすべての目的に合格させることができますか?私はArrayListとObjectを作成して新しく作成したActivityにそれらを渡すべきですか(ありがとう) –
あなたは意図した意図を使わなければなりません。また、さまざまなアクティビティに関連するアサーションには、異なるテストケースを使用する必要があります。 –