내 문제 : I는 건너 뛰기 버튼을 클릭 할 수없는이기 때문에단위 테스트는 "태그를 포함"을 통해 레이아웃에 포함
나의 현재 단위 테스트 "onClickSkipButtonAndVerifyAppExists는"실패를 include layout = "@ layout/navigation_bar"내에 있습니다. 기본적으로 레이아웃은 왼쪽의 건너 뛰기 버튼과 오른쪽의 다음 버튼입니다. include 태그에서 뷰를 클릭 할 수 없기 때문에 실패하는 이유가 의심 스럽습니다.
나는 다음과 같은 시나리오가 :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ignite="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_activity_outer_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottom_bar">
<RelativeLayout
android:id="@+id/main_activity_inner"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/toolbar_app_bar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:theme="@style/AppTheme.AppBarOverlay"
android:background="@color/header_footer">
<com.digitalturbine.igniteui.view.DynamicLayoutToolbar
android:id="@+id/main_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
ignite:popupTheme="@style/AppTheme.PopupOverlay"
ignite:contentInsetStart="0dp"
android:background="@drawable/toolbarBackground"
ignite:layoutType="left_two_line_title_w_icon"/>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/content_container"
android:layout_below="@+id/toolbar_app_bar"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
<View
android:id="@+id/main_activity_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/wizard_disabled_overlay"
android:visibility="gone"/>
</android.support.design.widget.CoordinatorLayout>
<LinearLayout
android:id="@+id/bottom_bar"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="@dimen/navigation_bar_height"
android:layout_alignParentBottom="true">
<include layout="@layout/navigation_bar"/>
</LinearLayout>
<FrameLayout
android:id="@+id/full_screen_content"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
제안 : :
사람이 제공 할 수있는 경우 또한
@RunWith(AndroidJUnit4.class)
@LargeTest
public class MainActivityTest {
@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<MainActivity>(MainActivity.class, true, true) {
@Override
protected void afterActivityLaunched() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Override
protected void afterActivityFinished() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
@Test
public void onClickSkipButtonAndVerifyAppExists() {
onView(withId(R.id.navigation_bar_skip)).perform(click());
}
}
을, 특정 시험에 대한 내 XML 레이아웃 파일은 다음과 같다 통찰력과 이것이 실제 문제라고 생각하지 마십시오. 이것이 문제가 될 수 있다고 결론을 내리기 전에 여러 가지 시도를했지만, 다시 한번 생각을 환영합니다.
실제로 MainActivity 클래스 때문입니다. 그 기능 중 하나가 제대로 실행되지 않아서 내가 경험 한 문제입니다. –