kotlintest 项目有一个示例结构

There is a sample structure for kotlintest project

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

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

没有特定的方法来专门为这个测试框架构建项目。你应该像任何其他 Kotlin 项目一样构建它,所以你的测试应该去 your-project/src/test/kotlin/com/jimmy/

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

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

Spek Test Example In Kotlin

主仓库中有一些 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,但您可以在上面的 link.

中找到它