[英]Unable to run Android Instrumented Tests
我正在嘗試在 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 個測試。 有什么我想念的嗎? 謝謝
如果 AS 顯示 TestResult 0/0,則刪除該依賴項
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0'
花了幾個小時后找到了解決這個問題的方法。 我注意到這個問題與
androidx.test.espresso:espresso-contrib:3.4.0
檢查此答案以獲取更多見解鏈接
以為我沒有收到任何錯誤或問題。 我不得不禁用 AS 的測試矩陣。 禁用后,我在邏輯上得到了更清晰的框架崩潰錯誤,這有助於我識別問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.