Integration tests with Gradle Kotlin DSL

前端 未结 4 983
梦谈多话
梦谈多话 2020-12-31 06:07

I\'m using this blog post to configure integration tests for a Spring Boot project, but I\'m pretty stuck on declaring the source sets. I also found this post on StackOverfl

4条回答
  •  天命终不由人
    2020-12-31 06:47

    I didnt like the use of withConvention and how the kotlin src dir was set. So after check out both gradle docs here and here, I came up with this:

    sourceSets {
        create("integrationTest") {
            kotlin {
                compileClasspath += main.get().output + configurations.testRuntimeClasspath
                runtimeClasspath += output + compileClasspath
            }
        }
    }
    
    val integrationTest = task("integrationTest") {
        description = "Runs the integration tests"
        group = "verification"
        testClassesDirs = sourceSets["integrationTest"].output.classesDirs
        classpath = sourceSets["integrationTest"].runtimeClasspath
        mustRunAfter(tasks["test"])
    }
    
    tasks.check {
        dependsOn(integrationTest)
    }
    

    I preferr the less verbose style when using kotlin { and the use of variable for the new integrationTestTask.

提交回复
热议问题