ES preSSO,android.support.test.es presso.NoActivityResumedException:在第一阶段没有活动的恢复。 [英] Espresso, android.support.test.espresso.NoActivityResumedException: No activities in stage RESUMED.

查看:959
本文介绍了ES preSSO,android.support.test.es presso.NoActivityResumedException:在第一阶段没有活动的恢复。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我试着写测试用例我的活动。我有几个活动,并有他们的一个没有问题的,而我得到以下错误,当我尝试运行在其他 ActivityTest 类的测试。

Hi I'm trying to write test cases for my activities. I have several activities and there is no issue for one of them while I'm getting following error when I try to run tests over other ActivityTest classes.

android.support.test.es presso.NoActivityResumedException:否
  在第一阶段活动的恢复。你忘了启动活动。
  (test.getActivity()或类似的)?

android.support.test.espresso.NoActivityResumedException: No activities in stage RESUMED. Did you forget to launch the activity. (test.getActivity() or similar)?

这是我的课,我所有的测试用例失败:

This is my class that all my test cases fails:

@RunWith(AndroidJUnit4.class)
@LargeTest
public class LocatingActivityTest
{
    @Rule
    public ActivityTestRule<LocatingActivity> mActivityTestRule = new ActivityTestRule<>(LocatingActivity.class);

    private LocatingActivity mLocatingActivity;

    @Before
    public void setup()
    {
        mLocatingActivity = mActivityTestRule.getActivity();
    }

    @Test
    public void viewsMustBeVisible()
    {
        onView(withId(R.id.locating_text)).check(matches(isCompletelyDisplayed()));
        onView(withId(R.id.sonarView)).check(matches(isCompletelyDisplayed()));
        onView(withId(R.id.locating_cancel_booking)).check(matches(isCompletelyDisplayed()));

        onView(withId(R.id.locating_list_view)).check(matches(isDisplayed()));
    }

    @Test
    public void viewsMustBeEnabled()
    {
        onView(withId(R.id.tvNoDriverFound)).check(matches(not(isCompletelyDisplayed())));
        onView(withId(R.id.tvNextSearch)).check(matches(not(isCompletelyDisplayed())));
    }
}

然而,这是我的另一个类,其所有的测试用例通过:

However this is my another class that all of its test cases passes:

@RunWith(AndroidJUnit4.class)
@LargeTest
public class BookingActivityTest
{
    @Rule
    public IntentsTestRule<BookingTaxiActivity> mActivityTestRule = new IntentsTestRule<>(BookingTaxiActivity.class);

    private BookingTaxiActivity mBookingTaxiActivity;

    @Before
    public void setup()
    {
        mBookingTaxiActivity = mActivityTestRule.getActivity();
    }

    @Test
    public void viewsMustBeVisible()
    {
        onView(withId(R.id.booking_pick_up_layout)).check(matches(isCompletelyDisplayed()));
        onView(withId(R.id.booking_drop_off_layout)).check(matches(isCompletelyDisplayed()));
        onView(withId(R.id.fab_booking)).check(matches(isCompletelyDisplayed()));
        onView(withId(R.id.booking_estimated_fare)).check(matches(isCompletelyDisplayed()));
        onView(withId(R.id.ibMenu)).check(matches(isCompletelyDisplayed()));
        onView(withId(R.id.booking_toolbar)).check(matches(isCompletelyDisplayed()));

        onView(withId(R.id.booking_taxi_type_picker)).check(matches(isDisplayed()));
    }

    @Test
    public void viewsMustBeEnabled()
    {
        // These Views are off the screen
        onView(withId(R.id.tag_widget)).check(matches(not(isCompletelyDisplayed())));
        onView(withId(R.id.payment_btn)).check(matches(not(isCompletelyDisplayed())));
        onView(withId(R.id.current_pickup_view)).check(matches(not(isCompletelyDisplayed())));
        onView(withId(R.id.advance_pickup_view)).check(matches(not(isCompletelyDisplayed())));
        onView(withId(R.id.booking_notes_btn)).check(matches(not(isCompletelyDisplayed())));
        onView(withId(R.id.promo_code_btn)).check(matches(not(isCompletelyDisplayed())));
        onView(withId(R.id.taxi_warning)).check(matches(not(isCompletelyDisplayed())));
        onView(withId(R.id.booking_book_now)).check(matches(not(isCompletelyDisplayed())));
    }
}

我不知道为什么上面的类的测试通过,而其他类的失败。任何想法是AP preciated。谢谢你。

I have no idea why tests of above class passes while other classes fails. Any idea would be appreciated. Thanks.

推荐答案

OK,我只是发现了一个痛苦的事实,居preSSO是无法从某处快乐路径运行活动。

OK, I just found a painful fact that Espresso is not able to run an Activity from somewhere in happy path.

比方说我幸福的路径包含活动A,B和C.我想我能,而无需调用活动A.所以这是不可能的,并导致上述错误运行活动B(或C)的测试。你应该做的就是点击你有活动A按钮,将活动B显示,以便能够执行你的测试,然后点击一个按钮(或进入下一个活动逻辑)调用活动C和执行您的测试

Lets say my happy path contains Activities A, B and C. I was thinking I'm able to run tests of Activity B (or C) without calling Activity A. So this is impossible and leads to above error. What you should do is click on a button you have on Activity A, The Activity B displays so you are able to perform your tests then click on a button (or a logic that goes to next activity) that calls Activity C and perform your tests.

这是超级痛苦:(
特别是我花了一个星期的事实去实现它。文档不受清楚地告诉它?!

This is super painful :( Particularly the fact that I spent a week to achieve it. Documentation is not subject to tell it clearly?!!!

这篇关于ES preSSO,android.support.test.es presso.NoActivityResumedException:在第一阶段没有活动的恢复。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆