From 53fde520d578a4eeb6ad14596d6d2dd8e58b2c4b Mon Sep 17 00:00:00 2001 From: "Alexander.Likhachev" Date: Wed, 23 Aug 2023 14:04:23 +0200 Subject: [PATCH] [Build] Add jUnit dependencies in `testApiJUnit5` to the `implementation` configuration Adding these dependencies to the `api` configuration pollutes classpath for each dependant modules even if it doesn't need them. Instead, the dependencies should be declared more granularly if they're required #KTI-1349 In Progress --- .../decompiler-to-file-stubs/build.gradle.kts | 4 +- .../decompiler-to-psi/build.gradle.kts | 4 +- analysis/decompiled/native/build.gradle.kts | 3 + .../symbol-light-classes/build.gradle.kts | 2 + build-common/build.gradle.kts | 2 +- .../org/jetbrains/kotlin/util/assertions.kt | 56 +++++++++++++++++++ compiler/android-tests/build.gradle.kts | 4 +- compiler/build.gradle.kts | 2 +- compiler/cli/build.gradle.kts | 2 +- compiler/container/build.gradle.kts | 2 +- .../legacy-fir-tests/build.gradle.kts | 2 +- .../fir/modularized-tests/build.gradle.kts | 2 +- .../build.gradle.kts | 2 +- .../classpathDiff/ClasspathSnapshotterTest.kt | 4 +- compiler/tests-different-jdk/build.gradle.kts | 4 +- compiler/util-klib-abi/build.gradle.kts | 1 + generators/test-generator/build.gradle.kts | 2 +- js/js.tests/build.gradle.kts | 2 +- .../jvm-embeddable-host/build.gradle.kts | 2 +- .../jvm-maven-deps/host/build.gradle.kts | 2 +- .../jvm-simple-script/host/build.gradle.kts | 2 +- libraries/scripting/common/build.gradle.kts | 2 +- .../scripting/dependencies/build.gradle.kts | 2 +- .../scripting/jsr223-test/build.gradle.kts | 2 +- libraries/scripting/jvm/build.gradle.kts | 2 +- ...tdlibJsExplicitDependencyResolutionTest.kt | 4 +- .../kotlin/gradle/unitTests/FutureTest.kt | 2 +- .../kotlin/gradle/unitTests/ZipUtilsTest.kt | 2 +- .../statistics/KotlinBuildStatHandlerTest.kt | 12 ++-- ...tlinJavaToolchainJavaVersionConvertTest.kt | 2 +- ...solatedKotlinPluginClassLoaderAwareTest.kt | 4 +- .../kotlin-main-kts-test/build.gradle.kts | 2 +- .../tools/kotlin-script-util/build.gradle.kts | 2 +- .../build.gradle.kts | 2 +- plugins/assign-plugin/build.gradle.kts | 3 +- .../atomicfu-compiler/build.gradle.kts | 2 +- .../fir-plugin-ic-test/build.gradle.kts | 1 + plugins/lombok/build.gradle.kts | 4 +- .../parcelize-compiler/build.gradle.kts | 2 +- .../scripting-compiler-impl/build.gradle.kts | 2 +- .../scripting-compiler/build.gradle.kts | 2 +- .../build.gradle.kts | 2 +- prepare/compiler-embeddable/build.gradle.kts | 2 +- .../src/main/kotlin/repoDependencies.kt | 6 +- wasm/wasm.tests/build.gradle.kts | 4 +- 45 files changed, 121 insertions(+), 55 deletions(-) create mode 100644 build-common/test/org/jetbrains/kotlin/util/assertions.kt diff --git a/analysis/decompiled/decompiler-to-file-stubs/build.gradle.kts b/analysis/decompiled/decompiler-to-file-stubs/build.gradle.kts index 78653a3f537..c155886605c 100644 --- a/analysis/decompiled/decompiler-to-file-stubs/build.gradle.kts +++ b/analysis/decompiled/decompiler-to-file-stubs/build.gradle.kts @@ -17,6 +17,8 @@ dependencies { testImplementation(projectTests(":compiler:tests-common")) testImplementation(projectTests(":compiler:tests-common-new")) testImplementation(projectTests(":analysis:analysis-test-framework")) + testImplementation(libs.junit.jupyter.api) + testRuntimeOnly(libs.junit.jupyter.engine) } sourceSets { @@ -24,7 +26,7 @@ sourceSets { "test" { projectDefault() } } -projectTest { +projectTest(jUnitMode = JUnitMode.JUnit5) { workingDir = rootDir } diff --git a/analysis/decompiled/decompiler-to-psi/build.gradle.kts b/analysis/decompiled/decompiler-to-psi/build.gradle.kts index 9a535f7751d..092f71b3671 100644 --- a/analysis/decompiled/decompiler-to-psi/build.gradle.kts +++ b/analysis/decompiled/decompiler-to-psi/build.gradle.kts @@ -18,6 +18,8 @@ dependencies { testImplementation(projectTests(":compiler:tests-common")) testImplementation(projectTests(":compiler:tests-common-new")) testImplementation(projectTests(":analysis:decompiled:decompiler-to-file-stubs")) + testImplementation(libs.junit.jupyter.api) + testRuntimeOnly(libs.junit.jupyter.engine) } sourceSets { @@ -25,7 +27,7 @@ sourceSets { "test" { projectDefault() } } -projectTest { +projectTest(jUnitMode = JUnitMode.JUnit5) { workingDir = rootDir } diff --git a/analysis/decompiled/native/build.gradle.kts b/analysis/decompiled/native/build.gradle.kts index 8790c026e1d..bb4464762e3 100644 --- a/analysis/decompiled/native/build.gradle.kts +++ b/analysis/decompiled/native/build.gradle.kts @@ -23,6 +23,9 @@ dependencies { api(project(":kotlin-util-klib-metadata")) compileOnly(intellijCore()) + testApi(platform(libs.junit.bom)) + testImplementation(libs.junit4) + testCompileOnly(libs.junit.jupiter.api) // the annotations are misused and have no effect testImplementation(projectTests(":compiler:tests-common")) testImplementation(projectTests(":compiler:tests-common-new")) testImplementation(projectTests(":analysis:decompiled:decompiler-to-file-stubs")) diff --git a/analysis/symbol-light-classes/build.gradle.kts b/analysis/symbol-light-classes/build.gradle.kts index 2502db8fa83..b8b88366f58 100644 --- a/analysis/symbol-light-classes/build.gradle.kts +++ b/analysis/symbol-light-classes/build.gradle.kts @@ -24,6 +24,8 @@ dependencies { testImplementation(projectTests(":analysis:analysis-api-fir")) testImplementation(projectTests(":compiler:tests-common-new")) testImplementation(projectTests(":analysis:low-level-api-fir")) + testImplementation(libs.junit.jupyter.api) + testRuntimeOnly(libs.junit.jupyter.engine) } sourceSets { diff --git a/build-common/build.gradle.kts b/build-common/build.gradle.kts index 8797ef72a46..a39b3cfa3b2 100644 --- a/build-common/build.gradle.kts +++ b/build-common/build.gradle.kts @@ -25,7 +25,7 @@ dependencies { testApi(projectTests(":compiler:tests-common")) testApiJUnit5() testImplementation(libs.junit.jupyter.params) - testApi(libs.junit4) + testImplementation(libs.junit4) testApi(protobufFull()) testApi(kotlinStdlib()) testImplementation(project(":compiler:build-tools:kotlin-build-statistics")) diff --git a/build-common/test/org/jetbrains/kotlin/util/assertions.kt b/build-common/test/org/jetbrains/kotlin/util/assertions.kt new file mode 100644 index 00000000000..37489432d34 --- /dev/null +++ b/build-common/test/org/jetbrains/kotlin/util/assertions.kt @@ -0,0 +1,56 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.util + +/** + * A replacement for the JUnit Jupiter function to be used in JUnit 4 tests. + * + * Asserts that the given code block throws an exception of the specified type. + * + * @param E the type of exception that is expected to be thrown + * @param message the error message to be used if the exception is not thrown + * @param body the code block to be executed and verified + * @return the caught exception if it is of the specified type + * @throws AssertionError if the specified exception is not thrown + */ +inline fun assertThrows( + message: String = "Expected ${E::class.java.name} to be thrown", + body: () -> Unit, +): Throwable { + try { + body() + } catch (e: Throwable) { + if (e is E) { + return e + } + } + throw AssertionError(message) +} + +/** + * A replacement for the JUnit Jupiter function to be used in JUnit 4 tests. + * + * Asserts that the specified code block does not throw any exception. + * + * @param message The message to be included in the AssertionError if an exception is thrown. + * It can contain the "{}" placeholder, which will be replaced with the thrown exception. + * @param body The code block to be executed. + * + * @return The result of executing the code block. + * + * @throws AssertionError If the code block throws an exception. + */ +fun assertDoesNotThrow( + message: String = "Expected no exception, but {} was thrown", + body: () -> R, +): R { + try { + return body() + } catch (e: Throwable) { + throw AssertionError(message.format(e)) + } +} + diff --git a/compiler/android-tests/build.gradle.kts b/compiler/android-tests/build.gradle.kts index df4a1104065..5d4d9f522a4 100644 --- a/compiler/android-tests/build.gradle.kts +++ b/compiler/android-tests/build.gradle.kts @@ -17,7 +17,7 @@ dependencies { testApi(kotlinStdlib()) testApi(projectTests(":compiler:tests-common")) - testApi(libs.junit4) + testImplementation(libs.junit4) testApi(projectTests(":compiler:test-infrastructure")) testApi(projectTests(":compiler:test-infrastructure-utils")) testApi(projectTests(":compiler:tests-compiler-utils")) @@ -29,7 +29,7 @@ dependencies { testRuntimeOnly(intellijCore()) testRuntimeOnly(commonDependency("org.jetbrains.intellij.deps.jna:jna")) - testApi(libs.junit.platform.launcher) + testImplementation(libs.junit.platform.launcher) } sourceSets { diff --git a/compiler/build.gradle.kts b/compiler/build.gradle.kts index 071e5795e4f..196a0f98ca1 100644 --- a/compiler/build.gradle.kts +++ b/compiler/build.gradle.kts @@ -16,7 +16,7 @@ dependencies { testApi(kotlinStdlib()) - testApi(libs.junit4) + testImplementation(libs.junit4) testCompileOnly(project(":kotlin-test:kotlin-test-jvm")) testCompileOnly(project(":kotlin-test:kotlin-test-junit")) testApi(projectTests(":compiler:tests-common")) diff --git a/compiler/cli/build.gradle.kts b/compiler/cli/build.gradle.kts index 086947a6534..f40274676ce 100644 --- a/compiler/cli/build.gradle.kts +++ b/compiler/cli/build.gradle.kts @@ -37,7 +37,7 @@ dependencies { testApi(project(":compiler:backend")) testApi(project(":compiler:cli")) testApi(projectTests(":compiler:tests-common")) - testApi(libs.junit4) + testImplementation(libs.junit4) } sourceSets { diff --git a/compiler/container/build.gradle.kts b/compiler/container/build.gradle.kts index 16b4cc366f4..da5afea243b 100644 --- a/compiler/container/build.gradle.kts +++ b/compiler/container/build.gradle.kts @@ -12,7 +12,7 @@ dependencies { testCompileOnly("org.jetbrains:annotations:13.0") testApi(project(":kotlin-test:kotlin-test-jvm")) testApi(project(":kotlin-test:kotlin-test-junit")) - testApi(libs.junit4) + testImplementation(libs.junit4) testCompileOnly(intellijCore()) testRuntimeOnly(intellijCore()) diff --git a/compiler/fir/analysis-tests/legacy-fir-tests/build.gradle.kts b/compiler/fir/analysis-tests/legacy-fir-tests/build.gradle.kts index 58a555c7e40..5b3b131fac9 100644 --- a/compiler/fir/analysis-tests/legacy-fir-tests/build.gradle.kts +++ b/compiler/fir/analysis-tests/legacy-fir-tests/build.gradle.kts @@ -13,7 +13,7 @@ plugins { dependencies { compileOnly(intellijCore()) - testApi(libs.junit4) + testImplementation(libs.junit4) testCompileOnly(project(":kotlin-test:kotlin-test-jvm")) testCompileOnly(project(":kotlin-test:kotlin-test-junit")) testApi(projectTests(":compiler:tests-common")) diff --git a/compiler/fir/modularized-tests/build.gradle.kts b/compiler/fir/modularized-tests/build.gradle.kts index cf3c53f814f..2879d1e5047 100644 --- a/compiler/fir/modularized-tests/build.gradle.kts +++ b/compiler/fir/modularized-tests/build.gradle.kts @@ -18,7 +18,7 @@ dependencies { testRuntimeOnly("xerces:xercesImpl:2.12.0") testRuntimeOnly(commonDependency("commons-lang:commons-lang")) - testApi(libs.junit4) + testImplementation(libs.junit4) testCompileOnly(project(":kotlin-test:kotlin-test-jvm")) testCompileOnly(project(":kotlin-test:kotlin-test-junit")) testApi(projectTests(":compiler:tests-common")) diff --git a/compiler/incremental-compilation-impl/build.gradle.kts b/compiler/incremental-compilation-impl/build.gradle.kts index 0e1f66d1838..fc10e0167d2 100644 --- a/compiler/incremental-compilation-impl/build.gradle.kts +++ b/compiler/incremental-compilation-impl/build.gradle.kts @@ -22,7 +22,7 @@ dependencies { api(project(":compiler:build-tools:kotlin-build-tools-api")) compileOnly(intellijCore()) - testApi(libs.junit4) + testImplementation(libs.junit4) testApi(project(":kotlin-test:kotlin-test-junit")) testApi(kotlinStdlib()) testApi(projectTests(":kotlin-build-common")) diff --git a/compiler/incremental-compilation-impl/test/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathSnapshotterTest.kt b/compiler/incremental-compilation-impl/test/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathSnapshotterTest.kt index d85d00ab9e2..5fc572fc4c6 100644 --- a/compiler/incremental-compilation-impl/test/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathSnapshotterTest.kt +++ b/compiler/incremental-compilation-impl/test/org/jetbrains/kotlin/incremental/classpathDiff/ClasspathSnapshotterTest.kt @@ -10,10 +10,8 @@ import org.jetbrains.kotlin.incremental.classpathDiff.ClasspathSnapshotTestCommo import org.jetbrains.kotlin.incremental.classpathDiff.ClasspathSnapshotTestCommon.SourceFile.JavaSourceFile import org.jetbrains.kotlin.incremental.classpathDiff.ClasspathSnapshotTestCommon.SourceFile.KotlinSourceFile import org.jetbrains.kotlin.incremental.classpathDiff.ClasspathSnapshotTestCommon.TestSourceFile -import org.junit.Assert.assertEquals +import org.junit.Assert.* import org.junit.Test -import org.junit.jupiter.api.Assertions.assertFalse -import org.junit.jupiter.api.Assertions.assertTrue import java.io.File private val testDataDir = diff --git a/compiler/tests-different-jdk/build.gradle.kts b/compiler/tests-different-jdk/build.gradle.kts index 1b3b9fcde84..3e0b3f620cc 100644 --- a/compiler/tests-different-jdk/build.gradle.kts +++ b/compiler/tests-different-jdk/build.gradle.kts @@ -11,8 +11,8 @@ dependencies { testApi(projectTests(":compiler:tests-common-new")) testApiJUnit5() - testApi(libs.junit.platform.runner) - testApi(libs.junit.platform.suite.api) + testImplementation(libs.junit.platform.runner) + testImplementation(libs.junit.platform.suite.api) runtimeOnly(libs.junit.vintage.engine) testImplementation(intellijCore()) diff --git a/compiler/util-klib-abi/build.gradle.kts b/compiler/util-klib-abi/build.gradle.kts index dd66bfe404d..931927a6539 100644 --- a/compiler/util-klib-abi/build.gradle.kts +++ b/compiler/util-klib-abi/build.gradle.kts @@ -10,6 +10,7 @@ dependencies { implementation(project(":compiler:ir.serialization.common")) compileOnly(commonDependency("org.jetbrains.intellij.deps.fastutil:intellij-deps-fastutil")) testApiJUnit5() + testImplementation(libs.junit.jupyter.params) testImplementation(intellijCore()) testImplementation(commonDependency("org.jetbrains.kotlin:kotlin-reflect")) { isTransitive = false } testImplementation(projectTests(":compiler:tests-common-new")) diff --git a/generators/test-generator/build.gradle.kts b/generators/test-generator/build.gradle.kts index 1c10018b1ac..55b4d63e4a9 100644 --- a/generators/test-generator/build.gradle.kts +++ b/generators/test-generator/build.gradle.kts @@ -8,7 +8,7 @@ dependencies { testApi(project(":core:util.runtime")) testApi(projectTests(":compiler:test-infrastructure-utils")) testApi(kotlinStdlib()) - testApi(libs.junit4) + testImplementation(libs.junit4) testApiJUnit5() testApi(project(":generators")) diff --git a/js/js.tests/build.gradle.kts b/js/js.tests/build.gradle.kts index 477c619c981..e61545128a0 100644 --- a/js/js.tests/build.gradle.kts +++ b/js/js.tests/build.gradle.kts @@ -55,7 +55,7 @@ dependencies { testApi(project(":js:js.dce")) testApi(project(":js:js.engines")) testApi(project(":compiler:incremental-compilation-impl")) - testApi(libs.junit4) + testImplementation(libs.junit4) testApi(projectTests(":kotlin-build-common")) testApi(projectTests(":generators:test-generator")) diff --git a/libraries/examples/scripting/jvm-embeddable-host/build.gradle.kts b/libraries/examples/scripting/jvm-embeddable-host/build.gradle.kts index eeef702211b..578e1afd65e 100644 --- a/libraries/examples/scripting/jvm-embeddable-host/build.gradle.kts +++ b/libraries/examples/scripting/jvm-embeddable-host/build.gradle.kts @@ -10,7 +10,7 @@ dependencies { testRuntimeOnly(project(":kotlin-scripting-compiler-embeddable")) testRuntimeOnly(project(":kotlin-scripting-jvm-host")) testRuntimeOnly(libs.guava) - testApi(libs.junit4) + testImplementation(libs.junit4) } sourceSets { diff --git a/libraries/examples/scripting/jvm-maven-deps/host/build.gradle.kts b/libraries/examples/scripting/jvm-maven-deps/host/build.gradle.kts index 3d1e2e6b9af..9e7c92ef34e 100644 --- a/libraries/examples/scripting/jvm-maven-deps/host/build.gradle.kts +++ b/libraries/examples/scripting/jvm-maven-deps/host/build.gradle.kts @@ -12,7 +12,7 @@ dependencies { testRuntimeOnly(project(":kotlin-compiler")) testRuntimeOnly(project(":kotlin-scripting-compiler")) - testApi(libs.junit4) + testImplementation(libs.junit4) } sourceSets { diff --git a/libraries/examples/scripting/jvm-simple-script/host/build.gradle.kts b/libraries/examples/scripting/jvm-simple-script/host/build.gradle.kts index 9cd17251264..b1fdc340f49 100644 --- a/libraries/examples/scripting/jvm-simple-script/host/build.gradle.kts +++ b/libraries/examples/scripting/jvm-simple-script/host/build.gradle.kts @@ -8,7 +8,7 @@ dependencies { api(project(":kotlin-scripting-jvm-host-unshaded")) testRuntimeOnly(project(":kotlin-compiler")) testRuntimeOnly(project(":kotlin-scripting-compiler")) - testApi(libs.junit4) + testImplementation(libs.junit4) } sourceSets { diff --git a/libraries/scripting/common/build.gradle.kts b/libraries/scripting/common/build.gradle.kts index b549dad0291..84ce7334146 100644 --- a/libraries/scripting/common/build.gradle.kts +++ b/libraries/scripting/common/build.gradle.kts @@ -8,7 +8,7 @@ project.updateJvmTarget("1.8") dependencies { api(kotlinStdlib()) compileOnly(commonDependency("org.jetbrains.kotlin:kotlin-reflect")) { isTransitive = false } - testApi(libs.junit4) + testImplementation(libs.junit4) } sourceSets { diff --git a/libraries/scripting/dependencies/build.gradle.kts b/libraries/scripting/dependencies/build.gradle.kts index b73d827cdd1..712ed391c73 100644 --- a/libraries/scripting/dependencies/build.gradle.kts +++ b/libraries/scripting/dependencies/build.gradle.kts @@ -8,7 +8,7 @@ project.updateJvmTarget("1.8") dependencies { api(kotlinStdlib()) api(project(":kotlin-scripting-common")) - testApi(libs.junit4) + testImplementation(libs.junit4) testImplementation(commonDependency("org.jetbrains.kotlinx", "kotlinx-coroutines-core")) } diff --git a/libraries/scripting/jsr223-test/build.gradle.kts b/libraries/scripting/jsr223-test/build.gradle.kts index 598009c1ec7..4a5f6b847e4 100644 --- a/libraries/scripting/jsr223-test/build.gradle.kts +++ b/libraries/scripting/jsr223-test/build.gradle.kts @@ -17,7 +17,7 @@ val testJsr223Runtime by configurations.creating { val testCompilationClasspath by configurations.creating dependencies { - testApi(libs.junit4) + testImplementation(libs.junit4) testCompileOnly(project(":kotlin-scripting-jvm-host-unshaded")) testCompileOnly(project(":compiler:cli")) testCompileOnly(project(":core:util.runtime")) diff --git a/libraries/scripting/jvm/build.gradle.kts b/libraries/scripting/jvm/build.gradle.kts index e5b63f5fadf..d76fd1a79d3 100644 --- a/libraries/scripting/jvm/build.gradle.kts +++ b/libraries/scripting/jvm/build.gradle.kts @@ -9,7 +9,7 @@ dependencies { api(project(":kotlin-script-runtime")) api(kotlinStdlib()) api(project(":kotlin-scripting-common")) - testApi(libs.junit4) + testImplementation(libs.junit4) } sourceSets { diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/dependencyResolutionTests/tcs/StdlibJsExplicitDependencyResolutionTest.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/dependencyResolutionTests/tcs/StdlibJsExplicitDependencyResolutionTest.kt index ea87cbf05a4..029884a2fc8 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/dependencyResolutionTests/tcs/StdlibJsExplicitDependencyResolutionTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/dependencyResolutionTests/tcs/StdlibJsExplicitDependencyResolutionTest.kt @@ -14,8 +14,8 @@ import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension import org.jetbrains.kotlin.gradle.plugin.ide.dependencyResolvers.resolveMetadata import org.jetbrains.kotlin.gradle.plugin.mpp.MetadataDependencyResolution import org.jetbrains.kotlin.gradle.util.* -import org.junit.jupiter.api.assertDoesNotThrow -import org.junit.jupiter.api.assertThrows +import org.jetbrains.kotlin.util.assertDoesNotThrow +import org.jetbrains.kotlin.util.assertThrows import kotlin.test.Test class StdlibJsExplicitDependencyResolutionTest { diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/FutureTest.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/FutureTest.kt index 38aab677aaf..6592b2885c3 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/FutureTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/FutureTest.kt @@ -17,8 +17,8 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinPluginLifecycle.Stage.ReadyForEx import org.jetbrains.kotlin.gradle.util.buildProject import org.jetbrains.kotlin.gradle.util.runLifecycleAwareTest import org.jetbrains.kotlin.gradle.utils.* +import org.jetbrains.kotlin.util.assertThrows import org.junit.Test -import org.junit.jupiter.api.assertThrows import java.util.concurrent.atomic.AtomicInteger import kotlin.test.* diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/ZipUtilsTest.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/ZipUtilsTest.kt index 83f0c350c1c..19fcb6914ef 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/ZipUtilsTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/ZipUtilsTest.kt @@ -11,9 +11,9 @@ import com.intellij.util.io.Compressor import org.gradle.kotlin.dsl.support.unzipTo import org.jetbrains.kotlin.gradle.utils.copyZipFilePartially import org.jetbrains.kotlin.gradle.utils.listDescendants +import org.jetbrains.kotlin.util.assertThrows import org.junit.Rule import org.junit.Test -import org.junit.jupiter.api.assertThrows import org.junit.rules.TemporaryFolder import java.io.File import java.util.zip.ZipEntry diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/plugin/statistics/KotlinBuildStatHandlerTest.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/plugin/statistics/KotlinBuildStatHandlerTest.kt index 79763bcf6c6..1a33e0239e9 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/plugin/statistics/KotlinBuildStatHandlerTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/plugin/statistics/KotlinBuildStatHandlerTest.kt @@ -9,14 +9,12 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType import org.jetbrains.kotlin.konan.target.KonanTarget import org.jetbrains.kotlin.statistics.metrics.StringAnonymizationPolicy import org.jetbrains.kotlin.statistics.metrics.StringMetrics -import org.junit.jupiter.api.DisplayName import kotlin.test.Test class KotlinBuildStatHandlerTest { - @DisplayName("Checks that all KonanTarget names are presented in MPP_PLATFORMS statistic's report validator") - @Test - fun mppPlatformsShouldContainsllKonanTargetsTest() { + @Test // Checks that all KonanTarget names are presented in MPP_PLATFORMS statistic's report validator + fun mppPlatformsShouldContainAllKonanTargetsTest() { val regex = Regex(StringMetrics.MPP_PLATFORMS.anonymization.validationRegexp()) val konanTargetsMissedInMppPlatforms = KonanTarget::class.sealedSubclasses @@ -28,8 +26,7 @@ class KotlinBuildStatHandlerTest { } } - @DisplayName("Checks that all KotlinPlatformType names are presented in MPP_PLATFORMS statistic's report validator") - @Test + @Test // Checks that all KotlinPlatformType names are presented in MPP_PLATFORMS statistic's report validator fun mppPlatformsShouldContainAllKotlinPlatformTypeTest() { val regex = Regex(StringMetrics.MPP_PLATFORMS.anonymization.validationRegexp()) @@ -43,8 +40,7 @@ class KotlinBuildStatHandlerTest { } - @DisplayName("Checks that only values listed in KotlinPlatformType and KonanTarget are included in MPP_PLATFORMS") - @Test + @Test // Checks that only values listed in KotlinPlatformType and KonanTarget are included in MPP_PLATFORMS fun mppPlatformsShouldContainOnlyKonanTargetsAndKotlinPlatformTypeTest() { val allowedMppValues = (StringMetrics.MPP_PLATFORMS.anonymization as StringAnonymizationPolicy.AllowedListAnonymizer) diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/tasks/KotlinJavaToolchainJavaVersionConvertTest.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/tasks/KotlinJavaToolchainJavaVersionConvertTest.kt index 930ed47d6e9..19118806a3c 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/tasks/KotlinJavaToolchainJavaVersionConvertTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/tasks/KotlinJavaToolchainJavaVersionConvertTest.kt @@ -15,8 +15,8 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptionsDefault import org.jetbrains.kotlin.gradle.utils.newInstance import org.jetbrains.kotlin.testhelpers.StubLogger +import org.jetbrains.kotlin.util.assertThrows import org.junit.Before -import org.junit.jupiter.api.assertThrows import java.io.File import kotlin.test.Test import kotlin.test.assertEquals diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/utils/CastIsolatedKotlinPluginClassLoaderAwareTest.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/utils/CastIsolatedKotlinPluginClassLoaderAwareTest.kt index 4e9591dd426..1f7ea1557c7 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/utils/CastIsolatedKotlinPluginClassLoaderAwareTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/utils/CastIsolatedKotlinPluginClassLoaderAwareTest.kt @@ -6,8 +6,8 @@ package org.jetbrains.kotlin.gradle.utils import org.jetbrains.kotlin.gradle.plugin.MULTIPLE_KOTLIN_PLUGINS_LOADED_WARNING +import org.jetbrains.kotlin.util.assertThrows import org.junit.AssumptionViolatedException -import org.junit.jupiter.api.assertThrows import java.net.URLClassLoader import kotlin.test.Test import kotlin.test.assertNull @@ -49,7 +49,7 @@ class CastIsolatedKotlinPluginClassLoaderAwareTest { assertTrue( MULTIPLE_KOTLIN_PLUGINS_LOADED_WARNING !in exception.message.orEmpty(), - "Expected no classpath warning in the error message, since this cast was not failing because of iosolated classloaders" + "Expected no classpath warning in the error message, since this cast was not failing because of isolated classloaders" ) } diff --git a/libraries/tools/kotlin-main-kts-test/build.gradle.kts b/libraries/tools/kotlin-main-kts-test/build.gradle.kts index a24c6551406..9c3aee4961f 100644 --- a/libraries/tools/kotlin-main-kts-test/build.gradle.kts +++ b/libraries/tools/kotlin-main-kts-test/build.gradle.kts @@ -12,7 +12,7 @@ dependencies { testCompileOnly(project(":compiler:cli")) testCompileOnly(project(":kotlin-scripting-jvm-host-unshaded")) testApi(kotlinStdlib("jdk8")) - testApi(libs.junit4) + testImplementation(libs.junit4) testApi(projectTests(":kotlin-scripting-compiler")) { isTransitive = false } testImplementation(project(":kotlin-compiler-embeddable")) kotlinxSerializationGradlePluginClasspath(project(":kotlinx-serialization-compiler-plugin.embeddable")) { isTransitive = false } diff --git a/libraries/tools/kotlin-script-util/build.gradle.kts b/libraries/tools/kotlin-script-util/build.gradle.kts index 1b61b31f082..662c219b6ab 100644 --- a/libraries/tools/kotlin-script-util/build.gradle.kts +++ b/libraries/tools/kotlin-script-util/build.gradle.kts @@ -17,7 +17,7 @@ dependencies { api(project(":kotlin-daemon-client")) testCompileOnly(project(":compiler:cli")) testApi(project(":kotlin-test:kotlin-test-junit")) - testApi(libs.junit4) + testImplementation(libs.junit4) testApi(project(":kotlin-scripting-compiler")) testRuntimeOnly(project(":kotlin-compiler")) testApi(intellijCore()) diff --git a/plugins/android-extensions/android-extensions-compiler/build.gradle.kts b/plugins/android-extensions/android-extensions-compiler/build.gradle.kts index bf301db08e2..159ecce9a8e 100644 --- a/plugins/android-extensions/android-extensions-compiler/build.gradle.kts +++ b/plugins/android-extensions/android-extensions-compiler/build.gradle.kts @@ -37,7 +37,7 @@ dependencies { testApi(project(":kotlin-android-extensions-runtime")) testApi(projectTests(":compiler:tests-common")) testApi(project(":kotlin-test:kotlin-test-jvm")) - testApi(libs.junit4) + testImplementation(libs.junit4) robolectricDependency("org.robolectric:android-all:5.0.2_r3-robolectric-r0") diff --git a/plugins/assign-plugin/build.gradle.kts b/plugins/assign-plugin/build.gradle.kts index 3e94372b9eb..b8cbc5373db 100644 --- a/plugins/assign-plugin/build.gradle.kts +++ b/plugins/assign-plugin/build.gradle.kts @@ -20,12 +20,13 @@ dependencies { testApi(projectTests(":compiler:tests-common-new")) testImplementation(projectTests(":compiler:tests-common")) - testImplementation(libs.junit4) + testImplementation(libs.junit.jupyter.api) testCompileOnly(project(":kotlin-reflect-api")) testRuntimeOnly(project(":kotlin-reflect")) testRuntimeOnly(project(":core:descriptors.runtime")) testRuntimeOnly(project(":compiler:fir:fir-serialization")) + testRuntimeOnly(libs.junit.jupyter.engine) testApi(intellijCore()) } diff --git a/plugins/atomicfu/atomicfu-compiler/build.gradle.kts b/plugins/atomicfu/atomicfu-compiler/build.gradle.kts index 58163887890..982d5b09833 100644 --- a/plugins/atomicfu/atomicfu-compiler/build.gradle.kts +++ b/plugins/atomicfu/atomicfu-compiler/build.gradle.kts @@ -83,7 +83,7 @@ dependencies { testImplementation(projectTests(":generators:test-generator")) testImplementation(projectTests(":js:js.tests")) - testApi(libs.junit4) + testImplementation(libs.junit4) testApi(project(":kotlin-test:kotlin-test-jvm")) // Dependencies for Kotlin/Native test infra: diff --git a/plugins/fir-plugin-prototype/fir-plugin-ic-test/build.gradle.kts b/plugins/fir-plugin-prototype/fir-plugin-ic-test/build.gradle.kts index c295ebb8175..ad2ebad2e8e 100644 --- a/plugins/fir-plugin-prototype/fir-plugin-ic-test/build.gradle.kts +++ b/plugins/fir-plugin-prototype/fir-plugin-ic-test/build.gradle.kts @@ -9,6 +9,7 @@ dependencies { testApi(project(":plugins:fir-plugin-prototype")) testApi(project(":compiler:incremental-compilation-impl")) testApi(projectTests(":compiler:incremental-compilation-impl")) + testImplementation(libs.junit.jupyter.api) testCompileOnly(intellijCore()) diff --git a/plugins/lombok/build.gradle.kts b/plugins/lombok/build.gradle.kts index 819520203eb..19129ce35c9 100644 --- a/plugins/lombok/build.gradle.kts +++ b/plugins/lombok/build.gradle.kts @@ -28,6 +28,7 @@ dependencies { testApi(projectTests(":compiler:tests-common-new")) testApi(projectTests(":compiler:test-infrastructure")) testApi(projectTests(":compiler:test-infrastructure-utils")) + testImplementation(libs.junit.jupyter.api) // FIR dependencies testApi(project(":compiler:fir:checkers")) @@ -35,8 +36,9 @@ dependencies { testRuntimeOnly(project(":compiler:fir:fir-serialization")) testRuntimeOnly(project(":core:descriptors.runtime")) + testRuntimeOnly(libs.junit.jupyter.engine) - testApi(libs.junit4) + testImplementation(libs.junit4) testRuntimeOnly(libs.guava) testRuntimeOnly(commonDependency("org.codehaus.woodstox:stax2-api")) diff --git a/plugins/parcelize/parcelize-compiler/build.gradle.kts b/plugins/parcelize/parcelize-compiler/build.gradle.kts index 5dff6628128..8625b22b289 100644 --- a/plugins/parcelize/parcelize-compiler/build.gradle.kts +++ b/plugins/parcelize/parcelize-compiler/build.gradle.kts @@ -53,7 +53,7 @@ dependencies { testRuntimeOnly(commonDependency("com.fasterxml:aalto-xml")) testRuntimeOnly("com.jetbrains.intellij.platform:util-xml-dom:$intellijVersion") { isTransitive = false } - testApi(libs.junit4) + testImplementation(libs.junit4) robolectricDependency("org.robolectric:android-all:5.0.2_r3-robolectric-r0") diff --git a/plugins/scripting/scripting-compiler-impl/build.gradle.kts b/plugins/scripting/scripting-compiler-impl/build.gradle.kts index ed5018f49e3..beb15737616 100644 --- a/plugins/scripting/scripting-compiler-impl/build.gradle.kts +++ b/plugins/scripting/scripting-compiler-impl/build.gradle.kts @@ -32,7 +32,7 @@ dependencies { testApi(project(":compiler:cli-common")) testApi(project(":compiler:frontend.java")) testApi(projectTests(":compiler:tests-common")) - testApi(libs.junit4) + testImplementation(libs.junit4) } sourceSets { diff --git a/plugins/scripting/scripting-compiler/build.gradle.kts b/plugins/scripting/scripting-compiler/build.gradle.kts index 84bc6e8c845..6399f16822d 100644 --- a/plugins/scripting/scripting-compiler/build.gradle.kts +++ b/plugins/scripting/scripting-compiler/build.gradle.kts @@ -32,7 +32,7 @@ dependencies { testApi(project(":compiler:cli-common")) testApi(project(":compiler:frontend.java")) testApi(projectTests(":compiler:tests-common")) - testApi(libs.junit4) + testImplementation(libs.junit4) testImplementation(intellijCore()) testImplementation(commonDependency("org.jetbrains.kotlinx", "kotlinx-coroutines-core")) diff --git a/prepare/compiler-client-embeddable/build.gradle.kts b/prepare/compiler-client-embeddable/build.gradle.kts index 06b2ecfa8f6..d5088310f1c 100644 --- a/prepare/compiler-client-embeddable/build.gradle.kts +++ b/prepare/compiler-client-embeddable/build.gradle.kts @@ -21,7 +21,7 @@ dependencies { testApi(project(":compiler:cli-common")) testApi(project(":daemon-common")) testApi(project(":kotlin-daemon-client")) - testApi(libs.junit4) + testImplementation(libs.junit4) testApi(project(":kotlin-test:kotlin-test-jvm")) testApi(project(":kotlin-test:kotlin-test-junit")) testCompilerClasspath(project(":kotlin-compiler")) diff --git a/prepare/compiler-embeddable/build.gradle.kts b/prepare/compiler-embeddable/build.gradle.kts index 4efc5e3f43f..f82c300566a 100644 --- a/prepare/compiler-embeddable/build.gradle.kts +++ b/prepare/compiler-embeddable/build.gradle.kts @@ -22,7 +22,7 @@ dependencies { runtimeOnly(commonDependency("org.jetbrains.kotlin:kotlin-reflect")) { isTransitive = false } runtimeOnly(project(":kotlin-daemon-embeddable")) runtimeOnly(commonDependency("org.jetbrains.intellij.deps", "trove4j")) - testApi(libs.junit4) + testImplementation(libs.junit4) testApi(project(":kotlin-test:kotlin-test-junit")) testCompilationClasspath(kotlinStdlib()) } diff --git a/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/repoDependencies.kt b/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/repoDependencies.kt index b4ef268c0a3..e3b76b4f4c8 100644 --- a/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/repoDependencies.kt +++ b/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/repoDependencies.kt @@ -197,13 +197,13 @@ fun Project.testApiJUnit5() { with(dependencies) { val libsVersionCatalog = libsVersionCatalog testApi(platform(libsVersionCatalog.findLibrary("junit-bom").orElseThrow { GradleException("No version for `junit-bom`") })) - testApi(libsVersionCatalog.findLibrary("junit-jupyter-api").orElseThrow { GradleException("No version for `junit-jupyter-api`") }) + testImplementation(libsVersionCatalog.findLibrary("junit-jupyter-api").orElseThrow { GradleException("No version for `junit-jupyter-api`") }) testRuntimeOnly( libsVersionCatalog.findLibrary("junit-jupyter-engine").orElseThrow { GradleException("No version for `junit-jupyter-engine`") }) - testApi( + testImplementation( libsVersionCatalog.findLibrary("junit-platform-commons") .orElseThrow { GradleException("No version for `junit-platform-commons`") }) - testApi( + testImplementation( libsVersionCatalog.findLibrary("junit-platform-launcher") .orElseThrow { GradleException("No version for `junit-platform-launcher`") }) } diff --git a/wasm/wasm.tests/build.gradle.kts b/wasm/wasm.tests/build.gradle.kts index d383b7414a5..1c4c614d665 100644 --- a/wasm/wasm.tests/build.gradle.kts +++ b/wasm/wasm.tests/build.gradle.kts @@ -61,10 +61,12 @@ val jsShell by configurations.creating { } dependencies { - testApi(libs.junit4) + testImplementation(libs.junit4) testApi(projectTests(":compiler:tests-common")) testApi(projectTests(":compiler:tests-common-new")) testApi(intellijCore()) + testImplementation(libs.junit.jupyter.api) + testRuntimeOnly(libs.junit.jupyter.engine) jsShell("org.mozilla:jsshell:$jsShellVersion:$jsShellSuffix@zip")