diff --git a/burst-gradle-plugin/src/test/kotlin/app/cash/burst/gradle/BurstGradlePluginTest.kt b/burst-gradle-plugin/src/test/kotlin/app/cash/burst/gradle/BurstGradlePluginTest.kt index bb277a1..736b1e2 100644 --- a/burst-gradle-plugin/src/test/kotlin/app/cash/burst/gradle/BurstGradlePluginTest.kt +++ b/burst-gradle-plugin/src/test/kotlin/app/cash/burst/gradle/BurstGradlePluginTest.kt @@ -212,6 +212,55 @@ class BurstGradlePluginTest { } } + @Test + fun burstValues() { + val projectDir = File("src/test/projects/burstValues") + + val taskName = ":lib:test" + val result = createRunner(projectDir, "clean", taskName).build() + assertThat(result.task(taskName)!!.outcome).isIn(*SUCCESS_OUTCOMES) + + val testResults = projectDir.resolve("lib/build/test-results") + + with(readTestSuite(testResults.resolve("test/TEST-CoffeeTest.xml"))) { + assertThat(testCases.map { it.name }).containsExactlyInAnyOrder( + "test", + "test_12", + "test_16", + ) + assertThat(systemOut).isEqualTo( + """ + |set up Decaf + |running Decaf 12 + |set up Decaf + |running Decaf 16 + |set up Decaf + |running Decaf 8 + | + """.trimMargin(), + ) + } + + with(readTestSuite(testResults.resolve("test/TEST-CoffeeTest_Regular.xml"))) { + assertThat(testCases.map { it.name }).containsExactlyInAnyOrder( + "test", + "test_12", + "test_16", + ) + assertThat(systemOut).isEqualTo( + """ + |set up Regular + |running Regular 12 + |set up Regular + |running Regular 16 + |set up Regular + |running Regular 8 + | + """.trimMargin(), + ) + } + } + private fun createRunner( projectDir: File, vararg taskNames: String, diff --git a/burst-gradle-plugin/src/test/projects/burstValues/build.gradle.kts b/burst-gradle-plugin/src/test/projects/burstValues/build.gradle.kts new file mode 100644 index 0000000..66fc2bb --- /dev/null +++ b/burst-gradle-plugin/src/test/projects/burstValues/build.gradle.kts @@ -0,0 +1,37 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile + +buildscript { + repositories { + maven { + url = file("$rootDir/../../../../../build/testMaven").toURI() + } + mavenCentral() + google() + } + dependencies { + classpath("app.cash.burst:burst-gradle-plugin:${project.property("burstVersion")}") + classpath(libs.kotlin.gradlePlugin) + } +} + +allprojects { + repositories { + maven { + url = file("$rootDir/../../../../../build/testMaven").toURI() + } + mavenCentral() + google() + } + + tasks.withType(JavaCompile::class.java).configureEach { + sourceCompatibility = "1.8" + targetCompatibility = "1.8" + } + + tasks.withType(KotlinJvmCompile::class.java).configureEach { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_1_8) + } + } +} diff --git a/burst-gradle-plugin/src/test/projects/burstValues/lib/build.gradle.kts b/burst-gradle-plugin/src/test/projects/burstValues/lib/build.gradle.kts new file mode 100644 index 0000000..36cb092 --- /dev/null +++ b/burst-gradle-plugin/src/test/projects/burstValues/lib/build.gradle.kts @@ -0,0 +1,8 @@ +plugins { + kotlin("jvm") + id("app.cash.burst") +} + +dependencies { + testImplementation(kotlin("test")) +} diff --git a/burst-gradle-plugin/src/test/projects/burstValues/lib/src/test/kotlin/CoffeeTest.kt b/burst-gradle-plugin/src/test/projects/burstValues/lib/src/test/kotlin/CoffeeTest.kt new file mode 100644 index 0000000..33f148d --- /dev/null +++ b/burst-gradle-plugin/src/test/projects/burstValues/lib/src/test/kotlin/CoffeeTest.kt @@ -0,0 +1,19 @@ +import app.cash.burst.Burst +import app.cash.burst.burstValues +import kotlin.test.BeforeTest +import kotlin.test.Test + +@Burst +class CoffeeTest( + private val espresso: String = burstValues("Decaf", "Regular", "Double"), +) { + @BeforeTest + fun setUp() { + println("set up $espresso") + } + + @Test + fun test(size: Int = burstValues(8, 12, 16)) { + println("running $espresso $size") + } +} diff --git a/burst-gradle-plugin/src/test/projects/burstValues/settings.gradle.kts b/burst-gradle-plugin/src/test/projects/burstValues/settings.gradle.kts new file mode 100644 index 0000000..78eeed4 --- /dev/null +++ b/burst-gradle-plugin/src/test/projects/burstValues/settings.gradle.kts @@ -0,0 +1,9 @@ +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + from(files("../../../../../gradle/libs.versions.toml")) + } + } +} + +include(":lib")