无法使用Espresso启动应用

时间:2019-07-03 07:54:17

标签: android android-studio android-espresso

我已经编写了基本的Android工具代码,以使用应用程序活动启动应用程序。问题是,它会启动应用程序并立即关闭它。

package com.esse.mail;

import android.content.Intent;
import android.support.test.espresso.ViewAssertion;
import android.support.test.espresso.assertion.ViewAssertions;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

@RunWith(AndroidJUnit4.class)
public class HomeScreenTest 
{
    @Rule
    public ActivityTestRule<HomeScreenActivity> mActivityRule = new 
    ActivityTestRule<>(HomeScreenActivity.class);

    @Before
    public void setUp()
    {
        mActivityRule.launchActivity(new Intent());
    }

    @Test
    public void testCompose()
    {

    }

    @After
    public void tearDown()
    {

    }
}

07/03 13:17:28: Launching HomeScreenTest
No apk changes detected since last installation, skipping installation of /Users/webyog/gem-test/falcon/mail/app/build/outputs/apk/debug/app-debug.apk
$ adb push /Users/webyog/gem-test/falcon/mail/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk /data/local/tmp/com.esse.mail.test
$ adb shell pm install --full -t -r "/data/local/tmp/com.esse.mail.test"
Success
APK installed in 385 ms
Running tests

$ adb shell am instrument -w -r   -e debug false -e class 'com.esse.mail.HomeScreenTest' com.esse.mail.test/android.support.test.runner.AndroidJUnitRunner
Client not ready yet..
Started running tests

我正在尝试使用android检测测试来运行此示例活动,但无法启动该应用。

0 个答案:

没有答案