Skip to content

Compatibility with Gradle TestKitopensavvy.prepared.compat.gradleGradlerunner

runner

suspend fun runner(): GradleRunner

Instantiates a GradleRunner in dir.

Examples

test("Create the root build.gradle.kts file") {
    gradle.rootProject.buildKts("""
        tasks.register("print") {
            doLast {
                println("Configuring the project")
            }
        }
    """.trimIndent()

    val result = gradle.runner()
        .withPluginClasspath()
        .withArguments("print")
        .build()

    result.output shouldContain "Configuring the project"
}

See also

  • GradleRunner.withPluginClasspathWhen writing tests for a plugin, automatically adds it to the executed Gradle instance

  • GradleRunner.withArgumentsSpecify which tasks should be executed

  • GradleRunner.buildExecutes the build, expecting a success

  • GradleRunner.buildAndFailExecutes the build, expecting a failure