Эспрессо не может начать другую деятельность - PullRequest
0 голосов
/ 18 мая 2018

Эспрессо не может найти вторую активность.Я пытаюсь выполнить простой тест с вызовом Espresso нового действия, но он всегда завершается неудачей с журналом ошибок ниже.Что мне делать правильно?

Это тестовый класс

public class LoginActivityTest {

    @Rule
    public ActivityTestRule<LoginActivity> mActivityTestRule = new ActivityTestRule<LoginActivity>(LoginActivity.class);

    private LoginActivity loginActivity = null;
    Instrumentation.ActivityMonitor monitor = getInstrumentation().addMonitor(SecondActivity.class.getName(), null, false);

    @Before
    public void setUp() throws Exception {
        loginActivity = mActivityTestRule.getActivity();
    }

    @Test
    public  void writeTestCase(){
        Espresso.onView(withId(R.id.email_sign_in_button)).perform(click());

        Activity secondActivity = getInstrumentation().waitForMonitorWithTimeout(monitor, 5000);
        assertNotNull(secondActivity);

        Espresso.onView(withId(R.id.email_sign_in_button)).check(matches(withId(R.id.first_number)));

    @After
    public void tearDown() throws Exception {
        loginActivity = null;
    }

}

Это журнал ошибок

java.lang.RuntimeException: No activities found. Did you t to launch the activity by calling getActivity() or startActivitySync or similar?
at android.support.test.espresso.base.RootViewPicker.waitForAtLeastOneActivityToBeResumed(RootViewPicker.java:169)
at android.support.test.espresso.base.RootViewPicker.get(RootViewPicker.java:83)
at android.support.test.espresso.ViewInteractionModule.provideRootView(ViewInteractionModule.java:77)
at android.support.test.espresso.ViewInteractionModule_ProvideRootViewFactory.proxyProvideRootView(ViewInteractionModule_ProvideRootViewFactory.java:34)
at android.support.test.espresso.ViewInteractionModule_ProvideRootViewFactory.get(ViewInteractionModule_ProvideRootViewFactory.java:24)
at android.support.test.espresso.ViewInteractionModule_ProvideRootViewFactory.get(ViewInteractionModule_ProvideRootViewFactory.java:10)
at android.support.test.espresso.base.ViewFinderImpl.getView(ViewFinderImpl.java:62)
at android.support.test.espresso.ViewInteraction$2.call(ViewInteraction.java:273)
at android.support.test.espresso.ViewInteraction$2.call(ViewInteraction.java:265)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.Handler.handleCallback(Handler.java:836)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6251)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)

Tests ran to completion.
...