Mockk是否支持Kotlin 1.4.10?

3
我已将我的Android应用程序升级至kotlin 1.4.10版本。现在,在尝试使用spyk()类时,我的测试失败了,并显示了以下异常。
io.mockk.MockKException: Can't instantiate proxy for class com.aaa.bbb.ccc.MyClass

由于出现了奇怪的类转换异常,基本上就是指
cannot cast class com.aaa.bbb.ccc.MyClass to com.aaa.bbb.ccc.MyClass

为什么MockK试图将一个类强制转换为它自己?

当我的gradle测试依赖项如下时,我的测试失败:

def coroutines_version = '1.3.7'
def junit_version = '4.13'
def mockk_version = '1.10.0'
def archtesting_version = '2.1.0'
def unitils_version = '3.4.6'

testImplementation "junit:junit:$junit_version"
testImplementation "io.mockk:mockk:$mockk_version"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"
testImplementation "androidx.arch.core:core-testing:$archtesting_version"
testImplementation "androidx.test:core:1.3.0"
testImplementation "org.unitils:unitils-core:$unitils_version"
testImplementation 'org.robolectric:robolectric:4.4'

testImplementation "org.koin:koin-test:$koin_version"
testImplementation "junit:junit:4.13"
testImplementation "androidx.test.ext:junit:1.1.2"

androidTestImplementation "androidx.test.ext:junit:1.1.2"
androidTestImplementation "androidx.test.espresso:espresso-core:3.3.0"

当我恢复使用这些依赖项时,我的测试通过:-
def coroutines_version = '1.3.7'
def junit_version = '4.13'
def mockk_version = '1.10.0'
def archtesting_version = '2.1.0'
def unitils_version = '3.4.6'

testImplementation "junit:junit:$junit_version"
testImplementation "io.mockk:mockk:$mockk_version"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"
testImplementation "androidx.arch.core:core-testing:$archtesting_version"
testImplementation "androidx.test:core:1.2.0"
testImplementation "org.unitils:unitils-core:$unitils_version"
testImplementation 'org.robolectric:robolectric:4.3'

testImplementation "org.koin:koin-test:$koin_version"
testImplementation "androidx.test.ext:junit:1.1.1"
androidTestImplementation "androidx.test.ext:junit:1.1.1"
androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0"
1个回答

0

是的,从1.11.0开始,Mockk支持Kotlin 1.4.x。(您正在使用Kotlin 1.3.61的1.10.0版本)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接