小编All*_*len的帖子

从命令行进行UiAutomator 2.0测试

我正在尝试使用Android UIAutomator进行一些简单的测试,我知道它需要由Gradle构建,因为UIAutomator 2.0,我可以运行我的简单测试,它只通过Android Studio或命令行按下主页按钮"gradlew .bat cC",我想知道如何用adb命令运行它?

我试过了

adb shell am instrument -w test.simple.uiatest/android.test.InstrumentationTestRunner
Run Code Online (Sandbox Code Playgroud)

正如这里建议的那样,但我明白了

INSTRUMENTATION_STATUS: id=ActivityManagerService
INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{test.simple.uiatest/android.test.InstrumentationTestRunner}
INSTRUMENTATION_STATUS_CODE: -1
android.util.AndroidException: INSTRUMENTATION_FAILED: test.simple.uiatest/android.test.InstrumentationTestRunner
    at com.android.commands.am.Am.runInstrument(Am.java:951)
    at com.android.commands.am.Am.onRun(Am.java:316)
    at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
    at com.android.commands.am.Am.main(Am.java:99)
    at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:250)
Run Code Online (Sandbox Code Playgroud)

下面是我的代码片段和build.gradle,我做错了什么?

package test.simple.uiatest;

import android.support.test.uiautomator.UiDevice;
import android.test.InstrumentationTestCase;

public class ApplicationTest extends InstrumentationTestCase {
    private UiDevice theDevice;

    @Override
    public void setUp() throws Exception {
        super.setUp();
        theDevice = UiDevice.getInstance(getInstrumentation());

        theDevice.pressHome();
    }

    public void testName() throws Exception {
        theDevice.pressHome(); …
Run Code Online (Sandbox Code Playgroud)

junit instrumentation android android-uiautomator

4
推荐指数
1
解决办法
5061
查看次数