From bb9363c076f9ca0e057c019a206ed9947aabe7e4 Mon Sep 17 00:00:00 2001 From: Arseniy Pendryak Date: Tue, 3 Dec 2024 18:17:46 +0100 Subject: [PATCH] Make tests work - add explicit dependency on junit lib - add explicit dependency on platform test framework - create `testOutput` configuration for `common` module to share tests between modules. Actually, it's a hack. But the proper solution should use `java-test-fixtures` gradle plugin. And for some reason it doesn't work with the latest platform release (2024.3) --- build.gradle.kts | 5 +++++ common/build.gradle.kts | 5 +++++ .../kotlin/org/jetbrains/academy/test/MyBaseTest.kt | 0 3 files changed, 10 insertions(+) rename common/src/{main => testFixtures}/kotlin/org/jetbrains/academy/test/MyBaseTest.kt (100%) diff --git a/build.gradle.kts b/build.gradle.kts index 64e4fc5..a4daec6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,4 @@ +import org.jetbrains.intellij.platform.gradle.TestFrameworkType import org.jetbrains.intellij.platform.gradle.extensions.IntelliJPlatformDependenciesExtension import org.jetbrains.intellij.platform.gradle.extensions.IntelliJPlatformExtension import org.jetbrains.intellij.platform.gradle.extensions.IntelliJPlatformRepositoriesExtension @@ -12,6 +13,7 @@ val ideaVersion: String by project plugins { java + `java-test-fixtures` val kotlinVersion = "1.9.21" id("org.jetbrains.kotlin.jvm") version kotlinVersion apply false id("io.gitlab.arturbosch.detekt") version "1.23.1" @@ -46,6 +48,7 @@ configure(subprojects) { apply { plugin("java") plugin("kotlin") + plugin("java-test-fixtures") } // Configure detekt @@ -157,9 +160,11 @@ configure(subprojects.filter { it.name != "common" }) { intellijIdeaCommunity(ideaVersion, useInstaller = false) jetbrainsRuntime() bundledPlugins("com.intellij.java", "org.jetbrains.kotlin") + testFramework(TestFrameworkType.Bundled) } implementation(project(":common")) + testImplementation(testFixtures(project(":common"))) } tasks.register("restoreOriginalFiles") { diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 8410774..540bb2b 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.intellij.platform.gradle.TestFrameworkType + group = rootProject.group version = rootProject.version @@ -23,5 +25,8 @@ dependencies { intellijIdeaCommunity(ideaVersion, useInstaller = false) jetbrainsRuntime() bundledPlugins("com.intellij.java", "org.jetbrains.kotlin") + testFramework(TestFrameworkType.Bundled) } + + testFixturesApi("junit:junit:4.13.2") } diff --git a/common/src/main/kotlin/org/jetbrains/academy/test/MyBaseTest.kt b/common/src/testFixtures/kotlin/org/jetbrains/academy/test/MyBaseTest.kt similarity index 100% rename from common/src/main/kotlin/org/jetbrains/academy/test/MyBaseTest.kt rename to common/src/testFixtures/kotlin/org/jetbrains/academy/test/MyBaseTest.kt