1

我目前正在使用 Kotlin 测试框架https://github.com/kotlintest/kotlintest

我想知道是否有一种预期的方式来构建项目,我的意思是,就像我可以开始的基础项目一样。

4

3 回答 3

2

没有专门的方法来为这个测试框架构建项目。您应该将其构建为任何其他 Kotlin 项目,因此您的测试应该转到your-project/src/test/kotlin/com/jimmy/

重要的是从 kotlintest 扩展一个可用的基类,例如。WordSpec 您可以在 kotlintest 本身中看到这一切(结构和测试)的样子 - https://github.com/kotlintest/kotlintest/tree/master/src/test/kotlin/io/kotlintest

于 2017-12-28T16:01:25.457 回答
0

您可以使用 spek 测试您的代码,这是示例,这可能有助于在您的项目中实施。

Kotlin 中的 Spek 测试示例

于 2017-12-28T17:05:32.863 回答
0

这里的主仓库中有一些 KotlinTest 示例项目: https ://github.com/kotlintest/kotlintest/tree/master/kotlintest-samples

他们使用 KotlinTest 3.0.x,对于 gradle 用户,构建文件如下所示:

apply plugin: 'org.junit.platform.gradle.plugin'

buildscript {
    ext.kotlin_version = '1.2.31'
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.junit.platform:junit-platform-gradle-plugin:1.1.0"
    }
}

dependencies {
    testCompile 'io.kotlintest:kotlintest-runner-junit5:3.0.3'
}

我不会包含 Maven 示例,因为 pom.xml 很冗长,因为它是 XML,但您可以在上面的链接中找到它。

于 2018-03-29T13:27:25.130 回答