aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/basic
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/test/kotlin/basic')
-rw-r--r--plugins/base/src/test/kotlin/basic/FailOnWarningTest.kt2
-rw-r--r--plugins/base/src/test/kotlin/basic/LoggerTest.kt44
2 files changed, 45 insertions, 1 deletions
diff --git a/plugins/base/src/test/kotlin/basic/FailOnWarningTest.kt b/plugins/base/src/test/kotlin/basic/FailOnWarningTest.kt
index 2a927b97..982d6550 100644
--- a/plugins/base/src/test/kotlin/basic/FailOnWarningTest.kt
+++ b/plugins/base/src/test/kotlin/basic/FailOnWarningTest.kt
@@ -116,7 +116,7 @@ class FailOnWarningTest : BaseAbstractTest() {
}
private class ZeroErrorOrWarningCountDokkaLogger(
- logger: DokkaLogger = DokkaConsoleLogger
+ logger: DokkaLogger = DokkaConsoleLogger()
) : DokkaLogger by logger {
override var warningsCount: Int = 0
override var errorsCount: Int = 0
diff --git a/plugins/base/src/test/kotlin/basic/LoggerTest.kt b/plugins/base/src/test/kotlin/basic/LoggerTest.kt
new file mode 100644
index 00000000..92ffb539
--- /dev/null
+++ b/plugins/base/src/test/kotlin/basic/LoggerTest.kt
@@ -0,0 +1,44 @@
+package basic
+
+import org.jetbrains.dokka.utilities.DokkaConsoleLogger
+import org.jetbrains.dokka.utilities.LoggingLevel
+import org.jetbrains.dokka.utilities.MessageEmitter
+import org.junit.jupiter.api.Test
+import kotlin.test.assertFalse
+import kotlin.test.assertTrue
+
+class LoggerTest {
+ class AccumulatingEmitter : MessageEmitter {
+ val messages: MutableList<String> = mutableListOf()
+ override fun invoke(message: String) {
+ messages.add(message)
+ }
+ }
+
+ @Test
+ fun `should display info messages if logging is info`(){
+ val emitter = AccumulatingEmitter()
+ val logger = DokkaConsoleLogger(LoggingLevel.INFO, emitter)
+
+ logger.debug("Debug!")
+ logger.info("Info!")
+
+ assertTrue(emitter.messages.size > 0)
+ assertTrue(emitter.messages.any { it == "Info!" })
+ assertFalse(emitter.messages.any { it == "Debug!" })
+ }
+
+ @Test
+ fun `should not display info messages if logging is warn`(){
+ val emitter = AccumulatingEmitter()
+ val logger = DokkaConsoleLogger(LoggingLevel.WARN, emitter)
+
+ logger.warn("Warning!")
+ logger.info("Info!")
+
+
+ assertTrue(emitter.messages.size > 0)
+ assertFalse(emitter.messages.any { it.contains("Info!") })
+ assertTrue(emitter.messages.any { it.contains("Warning!") })
+ }
+} \ No newline at end of file