代码之家  ›  专栏  ›  技术社区  ›  Quintin Balsdon

Kotlin多平台移动设备的Hamcrest和Mock

  •  0
  • Quintin Balsdon  · 技术社区  · 5 年前

    我正在试着用英语写测试 shared a模块 KMM 项目在共享模块的build.gradle.kts文件中,我有以下内容:

    sourceSets {
        val commonMain by getting
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test-common"))
                implementation(kotlin("test-annotations-common"))
    
    
                //TODO: Hamcrest
                //implementation("junit:junit:4.12")
                //implementation("org.hamcrest:hamcrest-library:1.3")
    
                //TODO: Mockk
                //implementation("io.mockk:mockk:1.10.4")
            }
        }
        //...
    }
    

    我也尝试过:

    implementation(kotlin("[library]"))
    

    同样的结果是:IDE不再识别这些测试,我无法运行它们。

    0 回复  |  直到 5 年前
        1
  •  3
  •   Róbert Nagy    5 年前

    不幸的是,没有一个模拟库具有K/N支持(AFAIK)。

    这是 Mockk's K/N 和 Mockk's K/JS 供将来参考,或者您也可以查看 Touchlab's Karmok

    有关Hamcrest,请参阅他们的问题 here

        2
  •  0
  •   Quintin Balsdon    5 年前

    我收到了KMM团队的回复——我想我会把它放在这里作为参考

    https://github.com/Kotlin/kmm-sample/blob/master/shared/build.gradle.kts 例如

    推荐文章