[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:
committed by
Space Team
parent
309cecdefd
commit
905423aa17
@@ -159,6 +159,7 @@ kotlin {
|
||||
}
|
||||
}
|
||||
val jvmJUnitTest by getting {
|
||||
dependsOn(commonTest)
|
||||
kotlin.srcDir("junit/src/test/kotlin")
|
||||
}
|
||||
val jvmJUnit5 by getting {
|
||||
@@ -170,6 +171,7 @@ kotlin {
|
||||
}
|
||||
}
|
||||
val jvmJUnit5Test by getting {
|
||||
dependsOn(commonTest)
|
||||
kotlin.srcDir("junit5/src/test/kotlin")
|
||||
dependencies {
|
||||
runtimeOnly(libs.junit.jupiter.engine)
|
||||
@@ -185,6 +187,7 @@ kotlin {
|
||||
}
|
||||
}
|
||||
val jvmTestNGTest by getting {
|
||||
dependsOn(commonTest)
|
||||
kotlin.srcDir("testng/src/test/kotlin")
|
||||
dependencies {
|
||||
implementation("org.testng:testng:7.5.1")
|
||||
@@ -266,16 +269,23 @@ tasks {
|
||||
dependsOn(jvmJarTasks)
|
||||
}
|
||||
|
||||
val jvmTestTasks = jvmTestFrameworks.map { framework ->
|
||||
register("jvm${framework}Test", Test::class) {
|
||||
group = "verification"
|
||||
val compilation = kotlin.jvm().compilations["${framework}Test"]
|
||||
classpath = compilation.runtimeDependencyFiles + compilation.output.allOutputs
|
||||
testClassesDirs = compilation.output.classesDirs
|
||||
when (framework) {
|
||||
JvmTestFramework.JUnit -> useJUnit()
|
||||
JvmTestFramework.JUnit5 -> useJUnitPlatform()
|
||||
JvmTestFramework.TestNG -> useTestNG()
|
||||
val jvmTestTasks = jvmTestFrameworks.flatMap { framework ->
|
||||
listOf(false, true).map { excludeAsserterContributor ->
|
||||
register("jvm${framework}${if (excludeAsserterContributor) "NoAsserter" else ""}Test", Test::class) {
|
||||
group = "verification"
|
||||
val testCompilation = kotlin.jvm().compilations["${framework}Test"]
|
||||
classpath = testCompilation.runtimeDependencyFiles + testCompilation.output.allOutputs
|
||||
if (excludeAsserterContributor) {
|
||||
val mainCompilation = kotlin.jvm().compilations["$framework"]
|
||||
classpath -= mainCompilation.output.allOutputs
|
||||
filter.excludePatterns += "*ContributorTest"
|
||||
}
|
||||
testClassesDirs = testCompilation.output.classesDirs
|
||||
when (framework) {
|
||||
JvmTestFramework.JUnit -> useJUnit()
|
||||
JvmTestFramework.JUnit5 -> useJUnitPlatform()
|
||||
JvmTestFramework.TestNG -> useTestNG()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user