Я пытаюсь использовать UIAutomator для некоторых простых тестов, я знаю, что он должен быть построен Gradle с UIAutomator 2.0, я могу запустить мой простой тест, который только нажимает кнопку «домой» через Android Studio или в командной строке от "gradlew.bat cC", мне было интересно, как я могу запустить его с помощью команды adb?Тест UiAutomator 2.0 из командной строки
Я попытался
adb shell am instrument -w test.simple.uiatest/android.test.InstrumentationTestRunner
, как было предложено here, но я получаю
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)
Ниже мой фрагмент кода и 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();
}
}
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc2"
defaultConfig {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
applicationId "test.simple.uiatest"
minSdkVersion 21
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'LICENSE.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile 'com.android.support.test:runner:0.2'
androidTestCompile 'com.android.support.test:rules:0.2'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.0'
}