Browse Source

Print Gradle version used in tests

Also switch to JUnit 5, because the feature is not supported by JUnit 4
pull/113/head
Alexey Tsvetkov 4 years ago committed by Alexey Tsvetkov
parent
commit
b601ed9693
  1. 8
      gradle-plugins/compose/build.gradle.kts
  2. 4
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/DesktopApplicationTest.kt
  3. 11
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/GradlePluginTestBase.kt
  4. 10
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/GradleTestNameGenerator.kt
  5. 1
      gradle-plugins/compose/src/test/resources/junit-platform.properties

8
gradle-plugins/compose/build.gradle.kts

@ -32,7 +32,8 @@ dependencies {
compileOnly(kotlin("gradle-plugin-api"))
compileOnly(kotlin("gradle-plugin"))
testImplementation(gradleTestKit())
testImplementation("junit:junit:4.13")
testImplementation(platform("org.junit:junit-bom:5.7.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
fun embeddedCompileOnly(dep: String) {
compileOnly(dep)
@ -77,6 +78,11 @@ tasks.register("testMinGradleVersion", Test::class.java) {
}
fun Test.configureTest(gradleVersion: String) {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
dependsOn("publishToMavenLocal")
systemProperty("compose.plugin.version", BuildProperties.deployVersion(project))
systemProperty("gradle.version.for.tests", gradleVersion)

4
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/DesktopApplicationTest.kt

@ -4,8 +4,8 @@ import org.gradle.testkit.runner.TaskOutcome
import org.jetbrains.compose.desktop.application.internal.OS
import org.jetbrains.compose.desktop.application.internal.currentOS
import org.jetbrains.compose.test.*
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
class DesktopApplicationTest : GradlePluginTestBase() {
@Test

11
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/GradlePluginTestBase.kt

@ -1,13 +1,12 @@
package org.jetbrains.compose.test
import org.junit.Rule
import org.junit.rules.TemporaryFolder
import org.junit.jupiter.api.io.TempDir
import java.io.File
abstract class GradlePluginTestBase {
@Rule
@JvmField
val testDir: TemporaryFolder = TemporaryFolder()
@TempDir
lateinit var testWorkDir: File
fun testProject(name: String): TestProject =
TestProject(name, workingDir = testDir.root)
TestProject(name, workingDir = testWorkDir)
}

10
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/GradleTestNameGenerator.kt

@ -0,0 +1,10 @@
package org.jetbrains.compose.test
import org.junit.jupiter.api.DisplayNameGenerator
class GradleTestNameGenerator : DisplayNameGenerator.Standard() {
private val gradleVersion = "[Gradle '${TestProperties.gradleVersionForTests}']"
override fun generateDisplayNameForClass(testClass: Class<*>?): String =
super.generateDisplayNameForClass(testClass) + gradleVersion
}

1
gradle-plugins/compose/src/test/resources/junit-platform.properties

@ -0,0 +1 @@
junit.jupiter.displayname.generator.default=org.jetbrains.compose.test.GradleTestNameGenerator
Loading…
Cancel
Save