[kotlin-test] Reconfigure JVM unit tests

- Include common annotations and assertions test source sets into each test platform test compilation in order to check how they work with that platform's annotations and asserter
- Run these tests without platform support jar to check the default asserter implementation
This commit is contained in:
Ilya Gorbunov
2024-01-18 15:53:37 +01:00
committed by Space Team
parent 309cecdefd
commit 905423aa17
+20 -10
View File
@@ -159,6 +159,7 @@ kotlin {
} }
} }
val jvmJUnitTest by getting { val jvmJUnitTest by getting {
dependsOn(commonTest)
kotlin.srcDir("junit/src/test/kotlin") kotlin.srcDir("junit/src/test/kotlin")
} }
val jvmJUnit5 by getting { val jvmJUnit5 by getting {
@@ -170,6 +171,7 @@ kotlin {
} }
} }
val jvmJUnit5Test by getting { val jvmJUnit5Test by getting {
dependsOn(commonTest)
kotlin.srcDir("junit5/src/test/kotlin") kotlin.srcDir("junit5/src/test/kotlin")
dependencies { dependencies {
runtimeOnly(libs.junit.jupiter.engine) runtimeOnly(libs.junit.jupiter.engine)
@@ -185,6 +187,7 @@ kotlin {
} }
} }
val jvmTestNGTest by getting { val jvmTestNGTest by getting {
dependsOn(commonTest)
kotlin.srcDir("testng/src/test/kotlin") kotlin.srcDir("testng/src/test/kotlin")
dependencies { dependencies {
implementation("org.testng:testng:7.5.1") implementation("org.testng:testng:7.5.1")
@@ -266,16 +269,23 @@ tasks {
dependsOn(jvmJarTasks) dependsOn(jvmJarTasks)
} }
val jvmTestTasks = jvmTestFrameworks.map { framework -> val jvmTestTasks = jvmTestFrameworks.flatMap { framework ->
register("jvm${framework}Test", Test::class) { listOf(false, true).map { excludeAsserterContributor ->
group = "verification" register("jvm${framework}${if (excludeAsserterContributor) "NoAsserter" else ""}Test", Test::class) {
val compilation = kotlin.jvm().compilations["${framework}Test"] group = "verification"
classpath = compilation.runtimeDependencyFiles + compilation.output.allOutputs val testCompilation = kotlin.jvm().compilations["${framework}Test"]
testClassesDirs = compilation.output.classesDirs classpath = testCompilation.runtimeDependencyFiles + testCompilation.output.allOutputs
when (framework) { if (excludeAsserterContributor) {
JvmTestFramework.JUnit -> useJUnit() val mainCompilation = kotlin.jvm().compilations["$framework"]
JvmTestFramework.JUnit5 -> useJUnitPlatform() classpath -= mainCompilation.output.allOutputs
JvmTestFramework.TestNG -> useTestNG() filter.excludePatterns += "*ContributorTest"
}
testClassesDirs = testCompilation.output.classesDirs
when (framework) {
JvmTestFramework.JUnit -> useJUnit()
JvmTestFramework.JUnit5 -> useJUnitPlatform()
JvmTestFramework.TestNG -> useTestNG()
}
} }
} }
} }