내 응용 프로그램에 대한 테스트 사례를 작성하는 중입니다. 활동에 적합합니다. 그러나 ViewPager 내부의 Fragment에 대해서는 내 사례가 실패합니다.Android Espresso Fragments 및 그 자녀의 사례를 Acitivty에서 작성하는 방법은 무엇인가요?
다음을 직접 실행하면 조각에 빈보기가 표시되므로 테스트 케이스가 실패합니다.
공용 클래스 SentimentsFragmentEspressoTest {
@Rule
public FragmentTestRule<SentimentsFragment> mFragmentTestRule = new FragmentTestRule<>(SentimentsFragment.class);
@Test
public void fragment_can_be_instantiated() {
// Launch the activity to make the fragment visible
mFragmentTestRule.launchActivity(null);
// Then use Espresso to test the Fragment
onView(withId(R.id.listSentiments))
.perform(RecyclerViewActions.scrollToPosition(4));
} }
그래서 사람이 어떻게이 문제를 온 이상 말해 줄 수 있습니까? 감사의 ViewPager 내부 조각에 대한 K. 인 Rajesh
아마도 'launchActivity (null);'을 호출했기 때문에 뷰가 비어 있거나 null이 될 가능성이 있습니다. –
@ H.Brooks, launchActivity()에는 Intent 매개 변수가 있습니다. 조각을 보내는 방법? – itsrajesh4uguys