无法 运行 Android 仪器化测试
Unable to run Android Instrumented Tests
我正在尝试 运行 在 AS Arctic Fox 2020.3.1 补丁 3 ARM 预览版上使用 espresso 进行一些 UI 测试。按照 Google 设置说明,这些是我的依赖项:
// Core library
androidTestImplementation 'androidx.test:core:1.4.0'
// AndroidJUnitRunner and JUnit Rules
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestUtil 'androidx.test:orchestrator:1.4.0'
// Assertions
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.ext:truth:1.4.0'
androidTestImplementation 'com.google.truth:truth:1.0.1'
// Espresso dependencies
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-web:3.4.0'
androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.4.0'
我还把 Gradle 中的 testInstrumentationRunner
添加到 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
我正在尝试 运行 下面最简单的测试:
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class DummyTest {
@Test
fun test() {
assert(false)
}
}
但是当我点击测试的 运行 时,我似乎有 0 个测试。有什么我想念的吗?谢谢
如果 AS 显示 TestResult 0/0 ,删除该依赖项
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0'
花了很多时间找到了解决这个问题的方法。我注意到这个问题与
androidx.test.espresso:espresso-contrib:3.4.0
查看此答案以获得更多见解link
以为我没有收到任何错误或问题。我不得不禁用 AS 的测试矩阵。禁用后,我在逻辑中得到了更清晰的框架崩溃错误,这帮助我确定了问题。
我正在尝试 运行 在 AS Arctic Fox 2020.3.1 补丁 3 ARM 预览版上使用 espresso 进行一些 UI 测试。按照 Google 设置说明,这些是我的依赖项:
// Core library
androidTestImplementation 'androidx.test:core:1.4.0'
// AndroidJUnitRunner and JUnit Rules
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestUtil 'androidx.test:orchestrator:1.4.0'
// Assertions
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.ext:truth:1.4.0'
androidTestImplementation 'com.google.truth:truth:1.0.1'
// Espresso dependencies
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-web:3.4.0'
androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.4.0'
我还把 Gradle 中的 testInstrumentationRunner
添加到 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
我正在尝试 运行 下面最简单的测试:
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class DummyTest {
@Test
fun test() {
assert(false)
}
}
但是当我点击测试的 运行 时,我似乎有 0 个测试。有什么我想念的吗?谢谢
如果 AS 显示 TestResult 0/0 ,删除该依赖项
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0'
花了很多时间找到了解决这个问题的方法。我注意到这个问题与
androidx.test.espresso:espresso-contrib:3.4.0
查看此答案以获得更多见解link
以为我没有收到任何错误或问题。我不得不禁用 AS 的测试矩阵。禁用后,我在逻辑中得到了更清晰的框架崩溃错误,这帮助我确定了问题。