【问题标题】:Unable to run Android Instrumented Tests无法运行 Android Instrumented 测试
【发布时间】:2022-01-11 20:46:16
【问题描述】:

我正在尝试在 AS Arctic Fox 2020.3.1 Patch 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 个测试。有什么我想念的吗?谢谢

【问题讨论】:

  • 我也遇到了同样的问题。
  • @Mona101ma 检查更新的答案

标签: android automated-tests android-espresso android-testing


【解决方案1】:

如果 AS 显示 TestResult 0/0 ,则删除该依赖项

androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0'

【讨论】:

    【解决方案2】:

    在花费数小时后找到了解决此问题的方法。我注意到这个问题与

    androidx.test.espresso:espresso-contrib:3.4.0
    

    查看此答案以获得更多见解link

    以为我没有收到任何错误或问题。我不得不禁用 AS 的测试矩阵。禁用后,我在逻辑上得到了更清晰的框架崩溃错误,这有助于我识别问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-05
      • 2023-03-28
      • 1970-01-01
      相关资源
      最近更新 更多