aboutsummaryrefslogtreecommitdiff
path: root/core/src/test/kotlin/format
diff options
context:
space:
mode:
authorAndrea Falcone <asfalcone@google.com>2020-02-03 16:52:31 -0500
committerAndrea Falcone <asfalcone@google.com>2020-02-05 11:11:34 -0500
commit459ec7288a872f7d927fd24cad5dbf33a93e10ac (patch)
tree881dfca07006808eaeb6d6d56a25c344617e572a /core/src/test/kotlin/format
parent897bc824aa83b4bd78ba6821c601fd254877e86b (diff)
downloaddokka-459ec7288a872f7d927fd24cad5dbf33a93e10ac.tar.gz
Refactor dac tests to use the same source for dac and dac-as-java tests
BUG: 144855335 Test: Dac tests from IDE Change-Id: I9755016a6ea176ed4ae8e98985532fb844dd68b3
Diffstat (limited to 'core/src/test/kotlin/format')
-rw-r--r--core/src/test/kotlin/format/DacAsJavaFormatTest.kt37
-rw-r--r--core/src/test/kotlin/format/DacFormatTest.kt43
-rw-r--r--core/src/test/kotlin/format/DacFormatTestCase.kt75
3 files changed, 75 insertions, 80 deletions
diff --git a/core/src/test/kotlin/format/DacAsJavaFormatTest.kt b/core/src/test/kotlin/format/DacAsJavaFormatTest.kt
deleted file mode 100644
index 7cf6e4b51..000000000
--- a/core/src/test/kotlin/format/DacAsJavaFormatTest.kt
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.jetbrains.dokka.tests.format
-
-import org.jetbrains.dokka.Formats.DacAsJavaFormatDescriptor
-import org.junit.Test
-
-class DacAsJavaFormatTest: DacFormatTestCase() {
- override val formatDescriptor = DacAsJavaFormatDescriptor()
- override val dokkaFormat = "dac-as-java"
-
- @Test
- fun javaSeeTag() {
- verifyDirectory("javaSeeTag")
- }
-
- @Test
- fun javaConstructor() {
- verifyDirectory("javaConstructor")
- }
-
- @Test
- fun javaDefaultConstructor() {
- verifyDirectory("javaDefaultConstructor")
- }
-
- @Test
- fun javaInheritedMethods() {
- verifyDirectory("inheritedMethods")
- }
-
- @Test fun javaMethodVisibilities() {
- verifyDirectory("javaMethodVisibilities")
- }
-
- @Test fun javaClassLinks() {
- verifyDirectory("javaClassLinks")
- }
-}
diff --git a/core/src/test/kotlin/format/DacFormatTest.kt b/core/src/test/kotlin/format/DacFormatTest.kt
index d37afa2e2..ae17420d4 100644
--- a/core/src/test/kotlin/format/DacFormatTest.kt
+++ b/core/src/test/kotlin/format/DacFormatTest.kt
@@ -1,21 +1,54 @@
package org.jetbrains.dokka.tests.format
+import org.jetbrains.dokka.Formats.DacAsJavaFormatDescriptor
import org.jetbrains.dokka.Formats.DacFormatDescriptor
+import org.jetbrains.dokka.Formats.JavaLayoutHtmlFormatDescriptorBase
import org.junit.Test
class DacFormatTest: DacFormatTestCase() {
- override val formatDescriptor = DacFormatDescriptor()
- override val dokkaFormat = "dac"
+ val dacFormatDescriptor = DacFormatDescriptor()
+ val dacAsJavaFormatDescriptor = DacAsJavaFormatDescriptor()
+ val dacFormat = "dac"
+ val dacAsJavaFormat = "dac-as-java"
+
+ private fun verifyBothFormats(directory: String) {
+ verifyDirectory(directory, dacFormatDescriptor, dacFormat)
+ verifyDirectory(directory, dacAsJavaFormatDescriptor, dacAsJavaFormat)
+ }
@Test fun javaSeeTag() {
- verifyDirectory("javaSeeTag")
+ verifyBothFormats("javaSeeTag")
}
@Test fun javaConstructor() {
- verifyDirectory("javaConstructor")
+ verifyBothFormats("javaConstructor")
+ }
+
+ @Test
+ fun javaSeeTagAsJava() {
+ verifyBothFormats("javaSeeTag")
+ }
+
+ @Test
+ fun javaConstructorAsJava() {
+ verifyBothFormats("javaConstructor")
+ }
+
+ @Test
+ fun javaDefaultConstructor() {
+ verifyBothFormats("javaDefaultConstructor")
+ }
+
+ @Test
+ fun javaInheritedMethods() {
+ verifyBothFormats("inheritedMethods")
+ }
+
+ @Test fun javaMethodVisibilities() {
+ verifyBothFormats("javaMethodVisibilities")
}
@Test fun javaClassLinks() {
- verifyDirectory("javaClassLinks")
+ verifyBothFormats("javaClassLinks")
}
} \ No newline at end of file
diff --git a/core/src/test/kotlin/format/DacFormatTestCase.kt b/core/src/test/kotlin/format/DacFormatTestCase.kt
index 221bee2ff..f3998c594 100644
--- a/core/src/test/kotlin/format/DacFormatTestCase.kt
+++ b/core/src/test/kotlin/format/DacFormatTestCase.kt
@@ -19,55 +19,54 @@ import java.io.File
import java.net.URI
abstract class DacFormatTestCase {
- abstract val formatDescriptor: JavaLayoutHtmlFormatDescriptorBase
- abstract val dokkaFormat: String
@get:Rule
var folder = TemporaryFolder()
- val injector: Injector by lazy {
- val options =
- DocumentationOptions(
- folder.toString(),
- dokkaFormat,
- apiVersion = null,
- languageVersion = null,
- generateClassIndexPage = false,
- generatePackageIndexPage = false,
- noStdlibLink = false,
- noJdkLink = false,
- collectInheritedExtensionsFromLibraries = true
- )
+ protected fun verifyDirectory(directory: String, formatDescriptor: JavaLayoutHtmlFormatDescriptorBase, dokkaFormat: String) {
+ val injector: Injector by lazy {
+ val options =
+ DocumentationOptions(
+ folder.toString(),
+ dokkaFormat,
+ apiVersion = null,
+ languageVersion = null,
+ generateClassIndexPage = false,
+ generatePackageIndexPage = false,
+ noStdlibLink = false,
+ noJdkLink = false,
+ collectInheritedExtensionsFromLibraries = true
+ )
- Guice.createInjector(Module { binder ->
+ Guice.createInjector(Module { binder ->
- binder.bind<Boolean>().annotatedWith(Names.named("generateClassIndex")).toInstance(false)
- binder.bind<Boolean>().annotatedWith(Names.named("generatePackageIndex")).toInstance(false)
+ binder.bind<Boolean>().annotatedWith(Names.named("generateClassIndex")).toInstance(false)
+ binder.bind<Boolean>().annotatedWith(Names.named("generatePackageIndex")).toInstance(false)
- binder.bind<String>().annotatedWith(Names.named("dacRoot")).toInstance("")
- binder.bind<String>().annotatedWith(Names.named("outlineRoot")).toInstance("")
- binder.bind<File>().annotatedWith(Names.named("outputDir")).toInstance(folder.root)
+ binder.bind<String>().annotatedWith(Names.named("dacRoot")).toInstance("")
+ binder.bind<String>().annotatedWith(Names.named("outlineRoot")).toInstance("")
+ binder.bind<File>().annotatedWith(Names.named("outputDir")).toInstance(folder.root)
- binder.bind<DocumentationOptions>().toProvider { options }
- binder.bind<DokkaLogger>().toInstance(object : DokkaLogger {
- override fun info(message: String) {
- println(message)
- }
+ binder.bind<DocumentationOptions>().toProvider { options }
+ binder.bind<DokkaLogger>().toInstance(object : DokkaLogger {
+ override fun info(message: String) {
+ println(message)
+ }
- override fun warn(message: String) {
- println("WARN: $message")
- }
+ override fun warn(message: String) {
+ println("WARN: $message")
+ }
- override fun error(message: String) {
- println("ERROR: $message")
- }
+ override fun error(message: String) {
+ println("ERROR: $message")
+ }
+ })
+
+ formatDescriptor.configureOutput(binder)
})
+ }
- formatDescriptor.configureOutput(binder)
- })
- }
- protected fun verifyDirectory(directory: String) {
- val directoryFile = File("testdata/format/$dokkaFormat/$directory")
+ val directoryFile = File("testdata/format/dac/$directory")
verifyModel(
JavaSourceRoot(directoryFile, null),
format = dokkaFormat
@@ -81,7 +80,7 @@ abstract class DacFormatTestCase {
byLocations.forEach { (loc, node) ->
val output = StringBuilder()
output.append(tmpFolder.resolve(URI("/").relativize(loc)).toURL().readText())
- val expectedFile = File(directoryFile, "${node.first().name}.html")
+ val expectedFile = File(File(directoryFile, dokkaFormat), "${node.first().name}.html")
assertEqualsIgnoringSeparators(expectedFile, output.toString())
}
}