android - Android 测试编排器未找到任何测试
问题描述
我正在使用 Kotlin 编程语言开发一个 Android 应用程序。我正在为我的应用程序编写仪器测试。我还使用测试编排器来运行我的检测测试。但是安装了修改Grandle文件的测试编排器后,我无法在Android Studio中运行测试。
我在 app.grandle 文件中添加了以下配置
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.memento"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
// testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "com.example.memento.MockTestRunner"
// Cleared between tests.
testInstrumentationRunnerArguments clearPackageData: 'true'
testOptions {
execution 'ANDROID_TEST_ORCHESTRATOR'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
有了这个
androidTestImplementation 'com.android.support.test:runner:1.1.1'
androidTestUtil 'com.android.support.test:orchestrator:1.1.1'
这是 MockTestRunner 类
导入 android.app.Application 导入 android.content.Context 导入 androidx.test.runner.AndroidJUnitRunner 导入 com.example.utils.MockApplicationController
class MockTestRunner: AndroidJUnitRunner()
{
override fun newApplication(
cl: ClassLoader?,
className: String?,
context: Context?
): Application {
return super.newApplication(cl, MockApplicationController::class.java!!.getName(), context)
}
}
然后,在 Android Studio 中,我尝试通过右键单击代码来运行测试,如下所示。
这是我运行测试时得到的。
$ adb shell CLASSPATH=$(pm path android.support.test.services) app_process / android.support.test.services.shellexecutor.ShellMain am instrument -r -w -e targetInstrumentation com.example.memento.test/com.example.memento.MockTestRunner -e debug false -e class 'com.example.memento.EventListTest#eventListIndexZeroTabRendersCurrentEvents' -e clearPackageData true android.support.test.orchestrator/android.support.test.orchestrator.AndroidTestOrchestrator
Waiting for process to come online...
Started running tests
Test running failed: No test results
从字面上看,没有运行测试。我的配置有什么问题,我该如何解决。如果我删除测试协调器安装,我可以运行测试并且它按预期工作。
解决方案
推荐阅读
- r - 如何从 R 中的变量中找出丢失的日期(例如 2018-08)
- reactjs - 实际上通过 CloudFront 提供内容?
- javascript - Oracle Apex 更改对象的字符串
- gradle - Gradle - 使用命令行参数创建自定义任务
- java - 登录检查后无法检索用户数据
- amazon-s3 - 如何通过自定义 kms 密钥启用服务器端加密将文件上传到 s3
- python - 如何将 args 元组传递给多处理池 imap?
- python - 矩阵大小不兼容:In[0]:[1,501760],In[1]:[25088,1024]
- vue.js - 如何将 vue @click 事件附加到输入字段旁边的字体真棒图标?
- task-parallel-library - 在产品微型 Prestashop 1.7 上显示产品可用尺寸