0

我创建了这个 android 测试:

package fr.tisseo.android.repository.productlocalization.tests

import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4ClassRunner::class)
class TodeleteTest {
    @Test
    fun testTodelete(){
        Assert.assertTrue(true)
    }
}

我有这个gradle配置:

defaultConfig {
    ...
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

//Unit testing
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test:rules:1.3.0'

当我运行我的测试时,我有这个错误:

$ adb shell am instrument -w -r -e debug false -e class 'fr.tisseo.android.repository.productlocalization.tests.TodeleteTest' fr.tisseo.android.debug.test/androidx.test.runner.AndroidJUnitRunner 连接到在设备“google-pixel_3-89KX0AP57”上处理 27190。

开始运行测试

java.lang.ClassNotFoundException:fr.tisseo.android.repository.productlocalization.tests.TodeleteTest

我在实施过程中遗漏了什么?

4

1 回答 1

0

我在启动 AndroidTest 目标时遇到了类似的问题。

Caused by: java.lang.ClassNotFoundException: Didn't find class .... on path: DexPathList[[zip file

我也使用了 Kotlin 源代码。添加apply plugin: 'kotlin-android'到 Gradle 配置文件解决了我的问题。

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

...
于 2021-06-04T20:30:34.917 回答