Ivan CLOVIS Canet
09/15/2024, 6:49 PMtest("A test that uses Gradle") {
// Create Kotlin or Grovvy DSL files directly…
gradle.settingsKts("""
include("foo")
""".trimIndent())
gradle.rootProject.buildKts("""
tasks.register("test") {
doLast {
println("Testing the root project")
}
}
""".trimIndent())
// …create multi-project builds easily…
gradle.project("foo").buildKts("""
tasks.register("test") {
doLast {
println("Testing the :foo project")
}
}
""".trimIndent())
// …start a Gradle instance in the related project…
val result = gradle.runner()
.withArguments("test")
.build()
// …assert that the output is as expected.
result.output shouldContain "Testing the root project"
result.output shouldContain "Testing the :foo project"
}
Each time the test runs, it creates a new clean directory in which all files are created and the build is run. If the test is successful, the directory is deleted. If the test fails, its path is printed and it is kept intact so you can visit it and analyze it further.Ramiro Aparicio Gallardo
09/17/2024, 6:54 AMIvan CLOVIS Canet
09/17/2024, 7:30 AM