【问题标题】:Ktor client MockEngine not resolved in androidKtor 客户端 MockEngine 未在 android 中解析
【发布时间】:2019-05-10 00:43:13
【问题描述】:

我已为 Ktor client mock

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

但 MockEngine 仍未解决。

【问题讨论】:

    标签: android kotlin ktor


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      我写了一篇关于 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

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

      【讨论】:

        猜你喜欢
        • 2021-05-03
        • 2020-06-23
        • 1970-01-01
        • 1970-01-01
        • 2020-05-03
        • 2020-04-15
        • 2018-11-22
        • 2012-04-02
        • 1970-01-01
        相关资源
        最近更新 更多