簡體   English   中英

JUnit本地測試-'未解決的參考:測試'

[英]JUnit Local Test - 'Unresolved reference: test'

預期

androidx.test:core:1.2.0androidx.test.ext:truth:1.2.0com.google.truth:truth:0.44等庫導入到名為ExampleUnitTest.kt本地JUnit測試類中。

觀測到的

錯誤

未解決的參考:測試

實作

ExampleUnitTest.kt

import androidx.test.core.app.ApplicationProvider.getApplicationContext
import com.google.common.truth.Truth.assertThat

這似乎是Android Testing Codelab示例應用程序中記錄的問題。

在Codelab示例build.gradle中,這被稱為已知問題。

// Once https://issuetracker.google.com/127986458 is fixed this can be testImplementation
implementation "androidx.test:core:$androidXTestCoreVersion"

我將應用的依賴關系重構為testImplementation而不是androidTestImplementation

testImplementation 'androidx.test:core:1.2.0'
testImplementation 'androidx.test.ext:truth:1.2.0'
testImplementation 'com.google.truth:truth:0.44'

注意 -應更新Google文檔“ AndroidX測試的設置”項目以反映此問題,因為它目前指示開發人員使用androidTestImplementation 我已提交文檔問題以解決此問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM