diff options
author | Marcin Aman <marcin.aman@gmail.com> | 2021-06-22 15:17:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-22 15:17:55 +0200 |
commit | 9e15f07aefe6ea1f366466c6721b92e77e3f1b41 (patch) | |
tree | 60ab664edbab02f3c128c1158a9490d06d44f66e /plugins/base/src/test/kotlin/basic/LoggerTest.kt | |
parent | 8d6536d3a3d0dcd80a2e6b77b047524e15533f0b (diff) | |
download | dokka-9e15f07aefe6ea1f366466c6721b92e77e3f1b41.tar.gz dokka-9e15f07aefe6ea1f366466c6721b92e77e3f1b41.tar.bz2 dokka-9e15f07aefe6ea1f366466c6721b92e77e3f1b41.zip |
Logging in CLI (#1976)
Diffstat (limited to 'plugins/base/src/test/kotlin/basic/LoggerTest.kt')
-rw-r--r-- | plugins/base/src/test/kotlin/basic/LoggerTest.kt | 44 |
1 files changed, 44 insertions, 0 deletions
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 |