From c63ea36637ce956029fb15b1482c0683ecb8a587 Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Wed, 30 Aug 2023 15:58:46 +0200 Subject: Migrate to JUnit 5 and unify used test API (#3138) --- .../dokka/gradle/ConfigureWithKotlinSourceSetGistTest.kt | 9 +++++---- .../dokka/gradle/DokkaConfigurationSerializableTest.kt | 11 +++-------- .../org/jetbrains/dokka/gradle/KotlinSourceSetGistTest.kt | 8 ++++---- 3 files changed, 12 insertions(+), 16 deletions(-) (limited to 'runners/gradle-plugin/src/test') diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/ConfigureWithKotlinSourceSetGistTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/ConfigureWithKotlinSourceSetGistTest.kt index 9594887c..f354159a 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/ConfigureWithKotlinSourceSetGistTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/ConfigureWithKotlinSourceSetGistTest.kt @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType import kotlin.test.Test import kotlin.test.assertEquals import org.jetbrains.dokka.gradle.utils.withDependencies_ +import kotlin.test.assertTrue class ConfigureWithKotlinSourceSetGistTest { @Test @@ -18,11 +19,11 @@ class ConfigureWithKotlinSourceSetGistTest { val f1Jar = project.file("f1.jar") val f2Jar = project.file("f2.jar") - check(f1Jar.createNewFile()) - check(f2Jar.createNewFile()) + assertTrue(f1Jar.createNewFile()) + assertTrue(f2Jar.createNewFile()) val customSourceRoot = project.file("customSourceRoot") - check(customSourceRoot.mkdirs()) + assertTrue(customSourceRoot.mkdirs()) val gist = KotlinSourceSetGist( name = "customName", @@ -112,7 +113,7 @@ class ConfigureWithKotlinSourceSetGistTest { ) val customSourceRoot = project.file("src/main/customRoot") - check(customSourceRoot.mkdirs()) + assertTrue(customSourceRoot.mkdirs()) mainSourceSet.kotlin.srcDir(customSourceRoot) assertEquals( diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt index b5230114..ed00c4b2 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt @@ -7,8 +7,7 @@ import org.jetbrains.dokka.PluginConfigurationImpl import org.jetbrains.dokka.gradle.utils.create_ import org.jetbrains.dokka.gradle.utils.externalDocumentationLink_ import org.jetbrains.dokka.gradle.utils.withDependencies_ -import org.junit.Rule -import org.junit.rules.TemporaryFolder +import org.junit.jupiter.api.io.TempDir import java.io.File import java.io.ObjectInputStream import java.io.ObjectOutputStream @@ -16,14 +15,10 @@ import java.net.URL import kotlin.test.Test import kotlin.test.assertEquals -@Suppress("UnstableApiUsage") class DokkaConfigurationSerializableTest { - @get:Rule - val temporaryFolder = TemporaryFolder() - @Test - fun `DokkaTask configuration write to file then parse`() { + fun `DokkaTask configuration write to file then parse`(@TempDir tempDirectory: File) { val project = ProjectBuilder.builder().build() project.plugins.apply("org.jetbrains.dokka") val dokkaTask = project.tasks.withType().first() @@ -66,7 +61,7 @@ class DokkaConfigurationSerializableTest { } val sourceConfiguration = dokkaTask.buildDokkaConfiguration() - val configurationFile = temporaryFolder.root.resolve("config.bin") + val configurationFile = tempDirectory.resolve("config.bin") ObjectOutputStream(configurationFile.outputStream()).use { stream -> stream.writeObject(sourceConfiguration) } diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinSourceSetGistTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinSourceSetGistTest.kt index 88bef2b2..976bff77 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinSourceSetGistTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinSourceSetGistTest.kt @@ -145,10 +145,10 @@ class KotlinSourceSetGistTest { ) /* Creating dependency files */ - check(implementationJar.createNewFile()) - check(compileOnlyJar.createNewFile()) - check(apiJar.createNewFile()) - check(runtimeOnlyJar.createNewFile()) + assertTrue(implementationJar.createNewFile()) + assertTrue(compileOnlyJar.createNewFile()) + assertTrue(apiJar.createNewFile()) + assertTrue(runtimeOnlyJar.createNewFile()) assertEquals( setOf(implementationJar, compileOnlyJar, apiJar), mainSourceSetGist.classpath.get().files, -- cgit