从不同的地方开始浓缩咖啡 activity

Start espresso from a different activity

我有一个应用程序在录制浓缩咖啡测试时启动初始 activity 屏幕。但是,我只想从登录后启动的另一个 activity 开始浓缩咖啡以及所有内容 (NavDrawerActivity)。基本上我想跳过登录等等。 这是我的代码的开头。有谁知道如何从 NavDrawerActivity 开始测试?

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

@Test
public void avatarActivityEspressoTest() {
    try {
        Thread.sleep(3000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    ViewInteraction appCompatButton = onView(
            allOf(withId(R.id.btn_skip), withText("SKIP"),
                    childAtPosition(
                            childAtPosition(
                                    withId(android.R.id.content),
                                    0),
                            4),
                    isDisplayed()));
    appCompatButton.perform(click());

    try {
        Thread.sleep(3000);
    } catch (InterruptedException e) {
        e.printStackTrace();
..
..

From Docs

ActivityTestRule to reduce the amount of boilerplate code you need to write. By using ActivityTestRule, the testing framework launches the activity under test before each test method annotated with @Test and before any method annotated with @Before

只需将规则更改为

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