Best Kotest code snippet using io.kotest.engine.config.dump.ProjectConfiguration.createConfigSummary
DumpTest.kt
Source:DumpTest.kt
1package com.sksamuel.kotest.engine.config2import io.kotest.core.config.ProjectConfiguration3import io.kotest.core.names.DuplicateTestNameMode4import io.kotest.core.annotation.Isolate5import io.kotest.core.spec.IsolationMode6import io.kotest.core.spec.SpecExecutionOrder7import io.kotest.core.spec.style.FunSpec8import io.kotest.core.test.TestCaseOrder9import io.kotest.engine.config.createConfigSummary10import io.kotest.matchers.string.shouldInclude11import kotlin.time.Duration.Companion.seconds12@Isolate13class DumpTest : FunSpec({14 test("dump should include test timeouts") {15 ProjectConfiguration().apply {16 timeout = 1217 invocationTimeout = 3423418 projectTimeout = 44444.seconds19 }.createConfigSummary().apply {20 this.shouldInclude("Default test timeout: 12ms")21 this.shouldInclude("Default test invocation timeout: 34234ms")22 this.shouldInclude("Overall project timeout: 12h 20m 44sms")23 }24 }25 test("dump should include affinity") {26 ProjectConfiguration().apply {27 timeout = 1228 invocationTimeout = 3423429 }.createConfigSummary().apply {30 this.shouldInclude("Dispatcher affinity: true")31 }32 }33 test("dump should include test order") {34 ProjectConfiguration().apply {35 testCaseOrder = TestCaseOrder.Random36 }.createConfigSummary().apply {37 this.shouldInclude("Default test execution order: Random")38 }39 }40 test("dump should include Spec execution order") {41 ProjectConfiguration().apply {42 specExecutionOrder = SpecExecutionOrder.Annotated43 }.createConfigSummary().apply {44 this.shouldInclude("Spec execution order: Annotated")45 }46 }47 test("dump should include Duplicate test name mode") {48 ProjectConfiguration().apply {49 duplicateTestNameMode = DuplicateTestNameMode.Silent50 }.createConfigSummary().apply {51 this.shouldInclude("Duplicate test name mode: Silent")52 }53 }54 test("dump should include default isolation mode") {55 ProjectConfiguration().apply {56 isolationMode = IsolationMode.InstancePerLeaf57 }.createConfigSummary().apply {58 this.shouldInclude("Default isolation mode: InstancePerLeaf")59 }60 }61 test("dump should include failOnEmptyTestSuite") {62 ProjectConfiguration().apply {63 failOnEmptyTestSuite = true64 }.createConfigSummary().apply {65 this.shouldInclude("Fail on empty test suite: true")66 }67 }68 test("dump should include coroutineDebugProbes") {69 ProjectConfiguration().apply {70 coroutineDebugProbes = true71 }.createConfigSummary().apply {72 this.shouldInclude("Coroutine debug probe: true")73 }74 }75 test("dump should include failOnIgnoredTests") {76 ProjectConfiguration().apply {77 failOnIgnoredTests = true78 }.createConfigSummary().apply {79 this.shouldInclude("Fail on ignored tests: true")80 }81 }82 test("dump should include globalAssertSoftly") {83 ProjectConfiguration().apply {84 globalAssertSoftly = true85 }.createConfigSummary().apply {86 this.shouldInclude("Global soft assertions: true")87 }88 }89})...
dump.kt
Source:dump.kt
1package io.kotest.engine.config2import io.kotest.core.config.ProjectConfiguration3import io.kotest.engine.tags.runtimeTags4import io.kotest.mpp.bestName5fun ProjectConfiguration.createConfigSummary(): String {6 val sb = StringBuilder()7 sb.buildOutput("Parallelization factor", parallelism.toString())8 sb.buildOutput("Concurrent specs", concurrentSpecs.toString())9 sb.buildOutput("Global concurrent tests", concurrentTests.toString())10 sb.buildOutput("Dispatcher affinity", dispatcherAffinity.toString())11 sb.buildOutput("Coroutine debug probe", coroutineDebugProbes.toString())12 sb.buildOutput("Spec execution order", specExecutionOrder.name)13 sb.buildOutput("Default test execution order", testCaseOrder.name)14 sb.buildOutput("Default test timeout", timeout.toString() + "ms")15 sb.buildOutput("Default test invocation timeout", invocationTimeout.toString() + "ms")16 if (projectTimeout != null)17 sb.buildOutput("Overall project timeout", projectTimeout.toString() + "ms")18 sb.buildOutput("Default isolation mode", isolationMode.name)19 sb.buildOutput("Global soft assertions", globalAssertSoftly.toString())20 sb.buildOutput("Write spec failure file", writeSpecFailureFile.toString())21 if (writeSpecFailureFile) {22 sb.buildOutput("Spec failure file path",23 specFailureFilePath.replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() })24 }25 sb.buildOutput("Fail on ignored tests", failOnIgnoredTests.toString())26 sb.buildOutput("Fail on empty test suite", failOnEmptyTestSuite.toString())27 sb.buildOutput("Duplicate test name mode", duplicateTestNameMode.name)28 if (includeTestScopeAffixes != null)29 sb.buildOutput("Include test scope affixes", includeTestScopeAffixes.toString())30 sb.buildOutput("Remove test name whitespace", removeTestNameWhitespace.toString())31 sb.buildOutput("Append tags to test names", testNameAppendTags.toString())32 if (registry.isNotEmpty()) {33 sb.buildOutput("Extensions")34 registry.all().map(::mapClassName).forEach {35 sb.buildOutput(it, indentation = 1)36 }37 }38 runtimeTags().expression?.let { sb.buildOutput("Tags", it) }39 return sb.toString()40}41fun ProjectConfiguration.dumpProjectConfig() {42 println("~~~ Kotest Configuration ~~~")43 println(createConfigSummary())44}45private fun StringBuilder.buildOutput(key: String, value: String? = null, indentation: Int = 0) {46 if (indentation == 0) {47 append("-> ")48 } else {49 for (i in 0 until indentation) {50 append(" ")51 }52 append("- ")53 }54 append(key)55 value?.let { append(": $it") }56 append("\n")57}58private fun mapClassName(any: Any) = any::class.bestName()...
ProjectConfiguration.createConfigSummary
Using AI Code Generation
1val config = ProjectConfiguration().apply {2 addSpec(MySpec::class)3 addSpec(MyOtherSpec::class)4}5config.dumpConfigSummary()6val config = ProjectConfiguration().apply {7 addSpec(MySpec::class)8 addSpec(MyOtherSpec::class)9}10config.dumpConfigSummary()11val config = ProjectConfiguration().apply {12 addSpec(MySpec::class)13 addSpec(MyOtherSpec::class)14}15config.dumpConfigSummary()16val config = ProjectConfiguration().apply {17 addSpec(MySpec::class)18 addSpec(MyOtherSpec::class)19}20config.dumpConfigSummary()21val config = ProjectConfiguration().apply {22 addSpec(MySpec::class)23 addSpec(MyOtherSpec::class)24}25config.dumpConfigSummary()26val config = ProjectConfiguration().apply {27 addSpec(MySpec::class)28 addSpec(MyOtherSpec::class)29}30config.dumpConfigSummary()31val config = ProjectConfiguration().apply {32 addSpec(MySpec::class)33 addSpec(MyOtherSpec::class)34}35config.dumpConfigSummary()36val config = ProjectConfiguration().apply {37 addSpec(MySpec::class)38 addSpec(MyOtherSpec::class)39}40config.dumpConfigSummary()41val config = ProjectConfiguration().apply {42 addSpec(MySpec::class)
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!