我需要在UI线程上运行一个测试,所以我想使用UiThreadTest
注释,但它没有解析该注释。我猜我必须在gradle文件中包含一个依赖项,但我不能为我的生活弄清楚它是什么。
@Test
@UiThreadTest
fun insertMultipleDelete() {
我的模块的构建。gradle依赖性:
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0'
def nav_version = "2.3.3"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
def room_version = "2.2.6"
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.room:room-ktx:$room_version"
kapt "androidx.room:room-compiler:$room_version"
testImplementation "androidx.room:room-testing:$room_version"
testImplementation 'androidx.test:core:1.3.0'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation "androidx.navigation:navigation-testing:$nav_version"
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
我需要做些什么来解决这个问题?
算出来了,你必须在gradle文件中包含androidTestImplementation 'androidx.test:rules:1.3.0'
在某个德国网站上找到的,感谢Google提供的优秀文档。