Ktor客户端MockEngine在Android中无法解析

时间:2018-12-08 13:58:53

标签: android kotlin ktor

我为 Ktor client mock

添加了依赖项
testImplementation "io.ktor:ktor-client-mock:$ktor_version"

但是仍然无法解析MockEngine。

2 个答案:

答案 0 :(得分:1)

这是一个没有 actual 实现的多平台模块。 要在平台模块中使用,对于android,应使用jvm相应的依赖项。在这种情况下,您应该改用:

testImplementation "io.ktor:ktor-client-mock-jvm:$ktor_version"

答案 1 :(得分:0)

我写了一篇有关Ktor和Ktor客户端模拟的文章,您可以在其中查看一个有效的示例。

https://medium.com/@xurxodev/how-to-create-a-rest-api-client-and-its-integration-tests-in-kotlin-multiplatform-d76c9a1be348

源代码在此GitHub存储库上 https://github.com/xurxodev/integration-testing-kotlin-multiplatform-kata

查看它,如果您有任何疑问,请告诉我

相关问题