aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/translators
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2023-08-30 15:58:46 +0200
committerGitHub <noreply@github.com>2023-08-30 15:58:46 +0200
commitc63ea36637ce956029fb15b1482c0683ecb8a587 (patch)
tree2b75a8a976b43530820e73dc60cce4b10d9fc005 /plugins/base/src/test/kotlin/translators
parent0e00edc6fcd406fcf38673ef6a2f8f59e8374de2 (diff)
downloaddokka-c63ea36637ce956029fb15b1482c0683ecb8a587.tar.gz
dokka-c63ea36637ce956029fb15b1482c0683ecb8a587.tar.bz2
dokka-c63ea36637ce956029fb15b1482c0683ecb8a587.zip
Migrate to JUnit 5 and unify used test API (#3138)
Diffstat (limited to 'plugins/base/src/test/kotlin/translators')
-rw-r--r--plugins/base/src/test/kotlin/translators/AccessorMethodNamingTest.kt6
-rw-r--r--plugins/base/src/test/kotlin/translators/Bug1341.kt4
-rw-r--r--plugins/base/src/test/kotlin/translators/DefaultDescriptorToDocumentableTranslatorTest.kt42
-rw-r--r--plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt34
-rw-r--r--plugins/base/src/test/kotlin/translators/ExternalDocumentablesTest.kt8
-rw-r--r--plugins/base/src/test/kotlin/translators/JavadocInheritDocsTest.kt8
-rw-r--r--plugins/base/src/test/kotlin/translators/JavadocInheritedDocTagsTest.kt6
-rw-r--r--plugins/base/src/test/kotlin/translators/JavadocParserTest.kt6
8 files changed, 53 insertions, 61 deletions
diff --git a/plugins/base/src/test/kotlin/translators/AccessorMethodNamingTest.kt b/plugins/base/src/test/kotlin/translators/AccessorMethodNamingTest.kt
index dee4bf7a..6f928266 100644
--- a/plugins/base/src/test/kotlin/translators/AccessorMethodNamingTest.kt
+++ b/plugins/base/src/test/kotlin/translators/AccessorMethodNamingTest.kt
@@ -2,9 +2,9 @@ package translators
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
import org.jetbrains.dokka.model.DProperty
-import org.junit.jupiter.api.Assertions.assertEquals
-import org.junit.jupiter.api.Assertions.assertTrue
-import org.junit.jupiter.api.Test
+import kotlin.test.Test
+import kotlin.test.assertEquals
+import kotlin.test.assertTrue
/**
* https://kotlinlang.org/docs/java-to-kotlin-interop.html#properties
diff --git a/plugins/base/src/test/kotlin/translators/Bug1341.kt b/plugins/base/src/test/kotlin/translators/Bug1341.kt
index 3e1b403d..97d75334 100644
--- a/plugins/base/src/test/kotlin/translators/Bug1341.kt
+++ b/plugins/base/src/test/kotlin/translators/Bug1341.kt
@@ -2,8 +2,8 @@ package translators
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
import org.jetbrains.dokka.links.DRI
-import org.junit.jupiter.api.Assertions.assertEquals
-import org.junit.jupiter.api.Test
+import kotlin.test.Test
+import kotlin.test.assertEquals
import utils.JavaCode
class Bug1341 : BaseAbstractTest() {
diff --git a/plugins/base/src/test/kotlin/translators/DefaultDescriptorToDocumentableTranslatorTest.kt b/plugins/base/src/test/kotlin/translators/DefaultDescriptorToDocumentableTranslatorTest.kt
index 4ae8f7ac..c8411f31 100644
--- a/plugins/base/src/test/kotlin/translators/DefaultDescriptorToDocumentableTranslatorTest.kt
+++ b/plugins/base/src/test/kotlin/translators/DefaultDescriptorToDocumentableTranslatorTest.kt
@@ -7,13 +7,9 @@ import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.links.PointingToDeclaration
import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.model.doc.*
-import org.junit.jupiter.api.Assertions.*
-import org.junit.jupiter.api.Disabled
-import org.junit.jupiter.api.Test
-import utils.OnlyDescriptors
import utils.text
-import kotlin.test.assertNotNull
-import kotlin.test.assertTrue
+import kotlin.test.*
+import utils.OnlyDescriptors
class DefaultDescriptorToDocumentableTranslatorTest : BaseAbstractTest() {
val configuration = dokkaConfiguration {
@@ -60,16 +56,17 @@ class DefaultDescriptorToDocumentableTranslatorTest : BaseAbstractTest() {
configuration
) {
documentablesMergingStage = { module ->
- assert(module.documentationOf("XD", "copy") == "")
- assert(
+ assertEquals("", module.documentationOf("XD", "copy"))
+ assertEquals(
+ "Memory is not what the heart desires. That is only a mirror.",
module.documentationOf(
"XD",
"equals"
- ) == "Memory is not what the heart desires. That is only a mirror."
+ )
)
- assert(module.documentationOf("XD", "hashCode") == "")
- assert(module.documentationOf("XD", "toString") == "")
- assert(module.documentationOf("XD", "custom") == "But the fat Hobbit, he knows. Eyes always watching.")
+ assertEquals("", module.documentationOf("XD", "hashCode"))
+ assertEquals("", module.documentationOf("XD", "toString"))
+ assertEquals("But the fat Hobbit, he knows. Eyes always watching.", module.documentationOf("XD", "custom"))
}
}
}
@@ -98,12 +95,13 @@ class DefaultDescriptorToDocumentableTranslatorTest : BaseAbstractTest() {
configuration
) {
documentablesMergingStage = { module ->
- assert(module.documentationOf("XD", "custom") == "But the fat Hobbit, he knows. Eyes always watching.")
- assert(
+ assertEquals("But the fat Hobbit, he knows. Eyes always watching.", module.documentationOf("XD", "custom"))
+ assertEquals(
+ "Memory is not what the heart desires. That is only a mirror.",
module.documentationOf(
"XD",
"equals"
- ) == "Memory is not what the heart desires. That is only a mirror."
+ )
)
}
}
@@ -656,7 +654,7 @@ val soapXml = node("soap-env:Envelope", soapAttrs,
}
}
- @Disabled // The compiler throws away annotations on unresolved types upstream
+ @Ignore // The compiler throws away annotations on unresolved types upstream
@Test
fun `Can annotate unresolved type`() {
testInline(
@@ -813,7 +811,7 @@ val soapXml = node("soap-env:Envelope", soapAttrs,
val testFunction = module.packages.find { it.name == "com.example" }
?.functions
?.single { it.name == "foo" }
- checkNotNull(testFunction)
+ assertNotNull(testFunction)
val documentationTags = testFunction.documentation.values.single().children
assertEquals(7, documentationTags.size)
@@ -873,7 +871,7 @@ val soapXml = node("soap-env:Envelope", soapAttrs,
val kotlinEnum = module.packages.find { it.name == "test" }
?.classlikes
?.single { it.name == "KotlinEnum" }
- checkNotNull(kotlinEnum)
+ assertNotNull(kotlinEnum)
val valuesFunction = kotlinEnum.functions.single { it.name == "values" }
val expectedValuesType = GenericTypeConstructor(
@@ -936,7 +934,7 @@ val soapXml = node("soap-env:Envelope", soapAttrs,
?.classlikes
?.single { it.name == "KotlinEnum" }
- checkNotNull(kotlinEnum)
+ assertNotNull(kotlinEnum)
val entriesProperty = kotlinEnum.properties.single { it.name == "entries" }
val expectedEntriesType = GenericTypeConstructor(
@@ -999,7 +997,7 @@ val soapXml = node("soap-env:Envelope", soapAttrs,
val kotlinEnum = module.packages.find { it.name == "test" }
?.classlikes
?.single { it.name == "KotlinEnum" }
- checkNotNull(kotlinEnum)
+ assertNotNull(kotlinEnum)
val expectedValueOfType = GenericTypeConstructor(
dri = DRI(
@@ -1067,9 +1065,9 @@ val soapXml = node("soap-env:Envelope", soapAttrs,
val pckg = module.packages.single { it.name == "test" }
val dataObject = pckg.classlikes.single { it.name == "KotlinDataObject" }
- assertInstanceOf(DObject::class.java, dataObject)
+ assertTrue(dataObject is DObject)
- val modifiers = (dataObject as DObject).modifiers().values.flatten()
+ val modifiers = dataObject.modifiers().values.flatten()
assertEquals(1, modifiers.size)
assertEquals(ExtraModifiers.KotlinOnlyModifiers.Data, modifiers[0])
}
diff --git a/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt b/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt
index b3f83d79..b75bc8e7 100644
--- a/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt
+++ b/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt
@@ -1,17 +1,13 @@
package translators
import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.DokkaConfiguration.Visibility
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.links.PointingToDeclaration
import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.model.doc.*
-import org.jetbrains.dokka.plugability.DokkaPlugin
-import org.jetbrains.dokka.plugability.DokkaPluginApiPreview
-import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement
-import org.jetbrains.dokka.DokkaConfiguration.Visibility
-import org.junit.jupiter.api.Assertions.*
-import org.junit.jupiter.api.Test
+import kotlin.test.*
import utils.JavaCode
@JavaCode
@@ -303,7 +299,7 @@ class DefaultPsiToDocumentableTranslatorTest : BaseAbstractTest() {
val testedClass = module.packages.single().classlikes.single { it.name == "JavaClassUsingAnnotation" }
val annotation = (testedClass as DClass).extra[Annotations]?.directAnnotations?.values?.single()?.single()
- checkNotNull(annotation)
+ assertNotNull(annotation)
assertEquals("JavaAnnotation", annotation.dri.classNames)
@@ -404,9 +400,7 @@ class DefaultPsiToDocumentableTranslatorTest : BaseAbstractTest() {
val testClass = module.packages.single().classlikes.single { it.name == "A" }
val getterLookalikes = testClass.functions.filter { it.name == "getA" }
- assertEquals(2, getterLookalikes.size) {
- "Not all expected regular functions found, wrongly categorized as getters?"
- }
+ assertEquals(2, getterLookalikes.size, "Not all expected regular functions found, wrongly categorized as getters?")
}
}
}
@@ -444,8 +438,8 @@ class DefaultPsiToDocumentableTranslatorTest : BaseAbstractTest() {
val setter = property.setter
assertNotNull(setter)
- assertEquals(1, setter?.parameters?.size)
- assertEquals(PrimitiveJavaType("int"), setter?.parameters?.get(0)?.type)
+ assertEquals(1, setter.parameters.size)
+ assertEquals(PrimitiveJavaType("int"), setter.parameters[0].type)
val regularSetterFunctions = testClass.functions.filter { it.name == "setA" }
assertEquals(4, regularSetterFunctions.size)
@@ -489,12 +483,14 @@ class DefaultPsiToDocumentableTranslatorTest : BaseAbstractTest() {
assertNotNull(field) {
"Expected the foo property to exist because the field is private with a public getter"
}
- assertNull(requireNotNull(field).setter)
+ assertNull(field.setter)
val setterMethodsWithSubtypeParams = testClass.functions.filter { it.name == "setFoo" }
- assertEquals(2, setterMethodsWithSubtypeParams.size) {
+ assertEquals(
+ 2,
+ setterMethodsWithSubtypeParams.size,
"Expected the setter methods to not qualify as accessors because of subtype parameters"
- }
+ )
}
}
}
@@ -517,9 +513,7 @@ class DefaultPsiToDocumentableTranslatorTest : BaseAbstractTest() {
val tetClass = module.packages.single().classlikes.single { it.name == "A" }
val property = tetClass.properties.firstOrNull { it.name == "a" }
- assertNull(property) {
- "Expected the property to stay private because there are no getters"
- }
+ assertNull(property, "Expected the property to stay private because there are no getters")
val regularSetterFunction = tetClass.functions.firstOrNull { it.name == "setA" }
assertNotNull(regularSetterFunction) {
@@ -757,7 +751,7 @@ class DefaultPsiToDocumentableTranslatorTest : BaseAbstractTest() {
val kotlinEnum = module.packages.find { it.name == "test" }
?.classlikes
?.single { it.name == "JavaEnum" }
- checkNotNull(kotlinEnum)
+ assertNotNull(kotlinEnum)
val valuesFunction = kotlinEnum.functions.single { it.name == "values" }
@@ -826,7 +820,7 @@ class DefaultPsiToDocumentableTranslatorTest : BaseAbstractTest() {
val javaEnum = module.packages.find { it.name == "test" }
?.classlikes
?.single { it.name == "JavaEnum" }
- checkNotNull(javaEnum)
+ assertNotNull(javaEnum)
val valueOfFunction = javaEnum.functions.single { it.name == "valueOf" }
diff --git a/plugins/base/src/test/kotlin/translators/ExternalDocumentablesTest.kt b/plugins/base/src/test/kotlin/translators/ExternalDocumentablesTest.kt
index c4087b20..56ecf06a 100644
--- a/plugins/base/src/test/kotlin/translators/ExternalDocumentablesTest.kt
+++ b/plugins/base/src/test/kotlin/translators/ExternalDocumentablesTest.kt
@@ -1,15 +1,15 @@
package translators
+import org.jetbrains.dokka.analysis.kotlin.internal.ExternalDocumentablesProvider
+import org.jetbrains.dokka.analysis.kotlin.internal.InternalKotlinAnalysisPlugin
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
import org.jetbrains.dokka.model.DClass
import org.jetbrains.dokka.model.DInterface
import org.jetbrains.dokka.plugability.plugin
import org.jetbrains.dokka.plugability.querySingle
import org.jetbrains.dokka.utilities.cast
-import org.jetbrains.dokka.analysis.kotlin.internal.ExternalDocumentablesProvider
-import org.jetbrains.dokka.analysis.kotlin.internal.InternalKotlinAnalysisPlugin
-import org.junit.jupiter.api.Assertions.assertEquals
-import org.junit.jupiter.api.Test
+import kotlin.test.Test
+import kotlin.test.assertEquals
import utils.OnlyDescriptors
import utils.UsingJDK
diff --git a/plugins/base/src/test/kotlin/translators/JavadocInheritDocsTest.kt b/plugins/base/src/test/kotlin/translators/JavadocInheritDocsTest.kt
index a357491f..0434a662 100644
--- a/plugins/base/src/test/kotlin/translators/JavadocInheritDocsTest.kt
+++ b/plugins/base/src/test/kotlin/translators/JavadocInheritDocsTest.kt
@@ -5,9 +5,9 @@ import org.jetbrains.dokka.model.doc.CustomDocTag
import org.jetbrains.dokka.model.doc.Description
import org.jetbrains.dokka.model.doc.P
import org.jetbrains.dokka.model.doc.Text
-import org.junit.jupiter.api.Assertions.assertEquals
-import org.junit.jupiter.api.Disabled
-import org.junit.jupiter.api.Test
+import kotlin.test.Ignore
+import kotlin.test.Test
+import kotlin.test.assertEquals
import utils.JavaCode
@JavaCode
@@ -132,7 +132,7 @@ class JavadocInheritDocsTest : BaseAbstractTest() {
}
@Test
- @Disabled("This should be enabled when we have proper tag inheritance in javadoc parser")
+ @Ignore // This should be enabled when we have proper tag inheritance in javadoc parser
fun `work when inherited part is empty in supertype but present in its supertype`() {
testInline(
"""
diff --git a/plugins/base/src/test/kotlin/translators/JavadocInheritedDocTagsTest.kt b/plugins/base/src/test/kotlin/translators/JavadocInheritedDocTagsTest.kt
index 1e3d784a..15bc31ed 100644
--- a/plugins/base/src/test/kotlin/translators/JavadocInheritedDocTagsTest.kt
+++ b/plugins/base/src/test/kotlin/translators/JavadocInheritedDocTagsTest.kt
@@ -5,11 +5,11 @@ import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.links.PointingToDeclaration
import org.jetbrains.dokka.model.DModule
import org.jetbrains.dokka.model.doc.*
-import org.junit.jupiter.api.Assertions.assertEquals
-import org.junit.jupiter.api.Test
-import utils.JavaCode
+import kotlin.test.Test
+import kotlin.test.assertEquals
import org.jetbrains.dokka.model.doc.Deprecated as DokkaDeprecatedTag
import org.jetbrains.dokka.model.doc.Throws as DokkaThrowsTag
+import utils.JavaCode
@JavaCode
class JavadocInheritedDocTagsTest : BaseAbstractTest() {
diff --git a/plugins/base/src/test/kotlin/translators/JavadocParserTest.kt b/plugins/base/src/test/kotlin/translators/JavadocParserTest.kt
index 8bc307df..85a5e9cf 100644
--- a/plugins/base/src/test/kotlin/translators/JavadocParserTest.kt
+++ b/plugins/base/src/test/kotlin/translators/JavadocParserTest.kt
@@ -7,10 +7,10 @@ import org.jetbrains.dokka.model.childrenOfType
import org.jetbrains.dokka.model.doc.*
import org.jetbrains.dokka.model.firstChildOfType
import org.jetbrains.dokka.model.firstMemberOfType
-import org.junit.jupiter.api.Assertions.assertEquals
-import org.junit.jupiter.api.Test
-import utils.JavaCode
import utils.text
+import kotlin.test.Test
+import kotlin.test.assertEquals
+import utils.JavaCode
@JavaCode
class JavadocParserTest : BaseAbstractTest() {