我想使用UiAutomater2为第三方应用程序编写自动化测试,我使用以下代码创建我的UiDevice:
UiDevice myDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
无论我尝试什么,它都会给我带来同样的错误,我已经在这2天中进行了任何操作,
java.lang.IllegalStateException: No instrumentation registered! Must run under a registering instrumentation.
adb devices命令可以看到我的设备,我可以使用UiAutomator1运行测试, Appium服务器工作正常,驱动程序完美连接到本地和云设备。
这是我的build.gradle,最近我经常在里面弄乱:
apply plugin: 'com.android.application'
android {
packagingOptions {
exclude 'LICENSE.txt'
}
compileSdkVersion 28
defaultConfig {
applicationId "com.example.mkiss.vonatinfo"
minSdkVersion 26
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
testOptions {
unitTests.returnDefaultValues = true
}
lintOptions {
abortOnError false
}
}
dependencies {
implementation 'com.android.support:support-annotations:27.1.1'
implementation 'com.android.support.test:testing-support-lib:0.1'
implementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
implementation 'io.appium:java-client:6.1.0'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
androidTestImplementation 'junit:junit:4.12'
}
感谢您的任何反馈!