https://kotlinlang.org logo
Join Slack
Powered by
# kotest
  • b

    Benoît Liessens

    07/29/2025, 6:07 AM
    Am I right to conclude that
    io.kotest.extensions:kotest-extensions-clock:1.0.0
    is obsolete as type
    TestClock
    is now part of
    io.kotest:kotest-extensions:6.0.0.M6
    ? The old clock extensions is still referenced in the 6.0.0 docs
    s
    e
    • 3
    • 43
  • o

    Oğuzhan Soykan

    07/29/2025, 10:09 AM
    I bumped to 6.0.0.M8, and now
    import io.kotest.data.*
    is missing. Is there a new package for data-driven testing?
    e
    p
    • 3
    • 9
  • p

    Piotr Krzemiński

    07/31/2025, 10:04 AM
    I'm trying to keep up with subsequent 6.0.0.Mx releases of kotest, and I'm a bit lost if some Maven artifacts are missing by mistake or by design. Are there any docs that enumerate breaking changes wrt. 5.x, and show how to migrate?
    b
    c
    s
    • 4
    • 11
  • s

    Sebastian Schuberth

    07/31/2025, 4:10 PM
    Any idea why I'm getting
    Copy code
    Caused by: java.lang.IllegalStateException: Could not locate a primary constructor for java.io.File
    	at io.kotest.property.arbitrary.JvmbindKt.forClassUsingConstructor(jvmbind.kt:104)
    	at io.kotest.property.arbitrary.TargetDefaultForClassNameKt.targetDefaultForType(targetDefaultForClassName.kt:100)
    	at io.kotest.property.arbitrary.JvmbindKt.forType(jvmbind.kt:150)
    	at io.kotest.property.arbitrary.JvmbindKt.arbForParameter(jvmbind.kt:136)
    with Kotest 5.9.1? Looks like there is an Arb implementation for
    File
    ...
    • 1
    • 3
  • p

    Piotr Krzemiński

    08/01/2025, 6:04 AM
    I'm wondering why kotest requires Java 11+ starting 6.0. I found the PR but there's no explanation: https://github.com/kotest/kotest/pull/4749. I'm asking because there's demand to use my library where I use kotest still with Java 8, and setting up some kind of dual building (releasing for 8, testing with 11) could make things complicated, so I'm just curious about the update to 11 on kotest's side. I realize that JDK 8 has been EOL for like 3 years, but well, it's still running somewhere out there 🤷
    a
    v
    b
    • 4
    • 26
  • p

    Piotr Krzemiński

    08/04/2025, 9:13 AM
    Hi! Is it possible that kotest 6.x doesn't work well with Gradle's Configuration Cache, or some extra piece of config is needed? see this CI run, I'm getting:
    Copy code
    - Task `:linuxX64Kotest` of type `io.kotest.framework.gradle.tasks.KotestNativeTask`: cannot serialize object of type 'org.gradle.api.DefaultTask', a subtype of 'org.gradle.api.Task', as these are not supported with the configuration cache.
      See <https://docs.gradle.org/8.14.3/userguide/configuration_cache.html#config_cache:requirements:task_access>
    - Task `:linuxX64Kotest` of type `io.kotest.framework.gradle.tasks.KotestNativeTask`: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache.
      See <https://docs.gradle.org/8.14.3/userguide/configuration_cache.html#config_cache:requirements:disallowed_types>
    - Task `:linuxX64Kotest` of type `io.kotest.framework.gradle.tasks.KotestNativeTask`: cannot serialize object of type 'org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeHostTest', a subtype of 'org.gradle.api.Task', as these are not supported with the configuration cache.
    When I turn off Configuration Cache, this problem is gone.
    b
    s
    • 3
    • 14
  • u

    Ulrik Rasmussen

    08/05/2025, 9:23 AM
    Sorry if this is a dumb question, but I am a bit confused about the kotest version numbering since 6.0.0.X. What does the
    M1
    ,
    M2
    , ..., suffixes mean? Does it indicate that it is a release candidate and not an official release, or did the scheme just change?
    o
    • 2
    • 2
  • p

    Petr Iakovenko

    08/09/2025, 9:37 AM
    Hi! I’m trying to switch from
    kotest-runner-junit5
    to
    kotest-framework-engine
    , but I’m running into a couple of issues that didn’t happen with the JUnit runner • debugging tests in IntelliJ doesn’t work — it just runs the test instead of debugging • logs only appear after the job has finished or been stopped (in the logs I see that it’s using
    listener=teamcity
    ) I’m running the tests using the Kotest plugin 6.0.0.M13
    s
    • 2
    • 5
  • m

    mudasar187

    08/11/2025, 1:08 PM
    Hi! im trying to update to latest
    6.0.0.M15
    , but this import/dependencies does not exists anymore?
    Copy code
    import io.kotest.data.forAll
    import io.kotest.data.row
    Tried to find any documentation for this, but cannot find anything?
    ✅ 1
    t
    k
    s
    • 4
    • 6
  • l

    LeoColman

    08/17/2025, 11:09 AM
    What am I doing wrong?
    Copy code
    class BambuMqttTransportSpec : FunSpec({
      val serial = "SER123"
      val access = "IGNORED"
    
      val mosquitto = install(ContainerExtension(GenericContainer("eclipse-mosquitto:2.0"))) {
        withExposedPorts(1883)
      }
      
      test("Basic connection to mosquitto container") {
        val mqttClient = MqttClient("tcp://${mosquitto.host}:${mosquitto.getMappedPort(1883)}", UUID.randomUUID().toString())
        mqttClient.connect()
        mqttClient.disconnect()
      }
      
    })
    In the test, connect fails because "Requested port (1883) is not mapped"
    s
    • 2
    • 2
  • p

    Piotr Krzemiński

    08/19/2025, 12:23 PM
    when can I find docs on migrating to kotest 6.0.0? I see a release in GitHub already and wanted to give it a shot
    plus1 4
  • s

    sam

    08/19/2025, 10:01 PM
    Migration docs will be available tomorrow
  • s

    sam

    08/19/2025, 10:02 PM
    WIP is here: https://github.com/kotest/kotest/blob/master/documentation/docs/release_6.0.md
    💪 3
    kotest intensifies 2
    👍 1
  • m

    Michael Strasser

    08/20/2025, 4:25 AM
    What is the Kotest Gradle plugin for? Why does it appear to require Google KSP as well?
    s
    • 2
    • 4
  • s

    sam

    08/21/2025, 1:27 AM
    Docs are updated for 6.0.
    gratitude thank you 1
    kotest intensifies 9
  • g

    Gopal S Akshintala

    08/21/2025, 10:00 AM
    Is
    withData
    not supported under StringSpec? https://kotest.io/docs/framework/datatesting/data-driven-testing.html Also are these fully removed in 6.0?
    Copy code
    import io.kotest.data.forAll
    import io.kotest.data.row
    If yes, where can I find the migration guide for
    StringSpec
    tests?
    p
    s
    o
    • 4
    • 6
  • n

    nerses

    08/21/2025, 9:04 PM
    Congrats on 6.0.0 release! Was this deleted in error? https://github.com/kotest/kotest/pull/4971/files#diff-632af0272c4724d187d3e88703e0e755236448de0b915f8e23c7010d2956e734L54
    s
    k
    • 3
    • 20
  • a

    Alexander Ioffe

    08/22/2025, 12:54 AM
    Hey @Emil Kantis. I think you should change your docs to tell folks to add KSP before kotest. Otherwise the build fails and it throws an error that has nothing to do with the problem at hand. When I do this:
    Copy code
    plugins {
      ...
      alias(libs.plugins.kotest)
      id("com.google.devtools.ksp") version "2.2.0-2.0.2"
    }
    Instead of this:
    Copy code
    plugins {
      ...
      id("com.google.devtools.ksp") version "2.2.0-2.0.2"
      alias(libs.plugins.kotest)
    }
    This happens:
    Copy code
    An exception occurred applying plugin request [id: 'io.kotest', version: '6.0.0']
    > Failed to apply plugin 'io.kotest'.
    > KSP neither found in root project nor exoquery-runner-core, please add 'com.google.devtools.ksp' to the project's plugins
    s
    • 2
    • 5
  • a

    Alexander Ioffe

    08/22/2025, 3:39 PM
    Also, I ran into another issue where I tried making my own extension of Free-spec (roughly) like this:
    Copy code
    abstract class MySpec(
      val variousStuff: VariousStuff,
      body: MySpec.() -> Unit
    ): FreeSpec(body as Function1<FreeSpec, Unit>) { ... }
    It works just fine for JVM but when I try doing a native (e.g. LinuxX64) it produces an invalid entry in
    kotest.kt
    that looks like this:
    Copy code
    SpecRef.Function ({ `Test1`() }, `Test1`::class, "my.stuff.Test1"), 
    SpecRef.Function ({ `Test2`() }, `Test2`::class, "my.stuff.Test2"), 
    SpecRef.Function ({ `MySpec`() }, `MySpec`::class, "my.stuff.MySpec"), 
    SpecRef.Function ({ `Test3`() }, `Test3`::class, "my.stuff.Test3"), 
    SpecRef.Function ({ `Test4`() }, `Test4`::class, "my.stuff.Test4"),
    I worked around it by making
    MySpec
    a regular (albeit open) class and adding a no-args constructor but it seems like a hack. Maybe the Kotest KSP could be modified to check if the class is abstract and then not add it to this list? I think you could do something like:
    Copy code
    (type:KSType).declaration.modifiers.contains(Modifier.ABSTRACT)
  • n

    nerses

    08/22/2025, 4:44 PM
    another place docs need updating is in extensions .e.g. https://kotest.io/docs/extensions/junit_xml.html where it says
    Copy code
    class MyConfig : AbstractProjectConfig() {
      override fun extensions(): List<Extension> = listOf(
        JunitXmlReporter(
          includeContainers = false, // don't write out status for all tests
          useTestPathAsName = true, // use the full test path (ie, includes parent test names)
          outputDir = "../target/junit-xml" // include to set output dir for maven
        )
      )
    }
    needs to change
    Copy code
    class MyConfig : AbstractProjectConfig() {
      override val extensions = listOf(
        JunitXmlReporter(
          includeContainers = false, // don't write out status for all tests
          useTestPathAsName = true, // use the full test path (ie, includes parent test names)
          outputDir = "../target/junit-xml" // include to set output dir for maven
        )
      )
    }
  • n

    nerses

    08/22/2025, 4:46 PM
    oh and https://kotest.io/docs/framework/project-config.html doesn't mention kotest.properties as it was in 5.x I am using that to configure where my project config is like this
    Copy code
    kotest.framework.config.fqn=com.expedia.www.cloudgate.KotestConfig
  • b

    Bart

    08/22/2025, 8:40 PM
    Hi, it looks like on 6.0.0 the issue with iOS tests is still present 😞.
  • o

    Olaf Gottschalk

    08/25/2025, 11:20 AM
    Hm... I just tried to upgrade from Kotest 5.9.1 to 6.0.1 and there are quite some changes I really, really dislike. E.g. the
    row
    function is missing (as I had to remove dataset dependency). And, another really bad design decision:
    withData
    is now implemented several times on the different specs - not as an extension on
    ContainerScope
    , but as different functions on
    FunSpecContainerScope
    ,
    StringSpecContainerScope
    , etc... This hurts a lot as I had my own extensions that used
    withData
    internally and now I have to go for the specific spec type, even though it used to be completely independent of the spec type used... anybody else bothered by that?
    👍 1
    s
    • 2
    • 2
  • o

    Olaf Gottschalk

    08/25/2025, 11:25 AM
    In Kotest 5.9.1, the artifact
    kotest-runner-junit5
    contained a dependency to
    kotlinx-coroutines
    , which was great as sometimes I needed Coroutines in my tests, e.g. with Arrow's Raise DSL, you need Coroutines. Now this transient dependency disappeared... the
    runTest
    function is not available anymore. This is really bad, as now my project which does not really do much else with Coroutines needs to depend on
    kotlinx-coroutines
    itself... I need to track down the latest version, etc. Can this be re-added? Any reason for removal?
    👍 1
    s
    • 2
    • 2
  • s

    Sebastian Schuberth

    08/25/2025, 7:37 PM
    Before Kotest 6, I was using
    withEnvironment
    in some Hoplite-related tests. Now that Kotest 6 removed
    withEnvironment
    , I wonder how I should implement those tests instead... esp. as Hoplite itself is also making use with `withEnvironment`.
    d
    • 2
    • 3
  • y

    Yuri

    08/26/2025, 3:06 PM
    Hello there! Our team just recently migrated to Kotest v6.0.1 and it declares support for Power-assert plugin for Kotlin 2.0+ I added plugin to project and added simple config:
    Copy code
    @OptIn(ExperimentalKotlinGradlePluginApi::class)
    powerAssert {
        functions = listOf("io.kotest.matchers.shouldBe")
    }
    During compilation I see "Internal compiler error" and with some following details:
    Copy code
    org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
    File being compiled: ***user route***
    The root cause java.lang.AssertionError was thrown at: org.jetbrains.kotlin.backend.jvm.lower.AddContinuationLoweringKt.retargetToSuspendView(AddContinuationLowering.kt:487)
    	at org.jetbrains.kotlin.backend.common.BackendException$Companion.report(BackendException.kt:31)
    	at org.jetbrains.kotlin.backend.common.BackendException$Companion.report$default(BackendException.kt:15)
    	at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(PerformByIrFilePhase.kt:37)
    	at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(PerformByIrFilePhase.kt:15)
    	at org.jetbrains.kotlin.backend.common.phaser.PhaseEngine.runPhase(PhaseEngine.kt:64)
    	at org.jetbrains.kotlin.backend.common.phaser.PhaseEngine.runPhase$default(PhaseEngine.kt:56)
    	at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.invokeLowerings(JvmIrCodegenFactory.kt:359)
        ...
    Caused by: java.lang.AssertionError: FUN LOCAL_FUNCTION_FOR_LAMBDA name:invokeSuspend$lambda$0 visibility:private modality:FINAL <> ... [suspend]
    	at org.jetbrains.kotlin.backend.jvm.lower.AddContinuationLoweringKt.retargetToSuspendView(AddContinuationLowering.kt:487)
        ...
    Maybe somebody faced the similar problem? Is this problem kotest-related?
    ✅ 1
    • 1
    • 1
  • t

    thanksforallthefish

    08/27/2025, 8:51 AM
    Hello 👋 is there a reason for https://github.com/kotest/kotest/commit/310338661ce8225bdbf276b555a48e5c59d5371a#diff-6087beb5b72897e627008db4414[…]ac1ba83bdc422bb5b1e07936bd649R23 returning nullable?
    null shouldBe true
    would anyway fail, so it should be possible to return non nullable. the "issue" with returning nullable is that something like
    true.shouldBeTrue().toArray()
    does not compile anymore, it has to be
    true.shouldBeTrue()?.toArray()
    with all the chaining issue (I should mention
    toArray
    is a custom extension function expecting a non-nullable receiver)
  • p

    Piotr Krzemiński

    08/27/2025, 12:05 PM
    here's an interesting case:
    obj shouldNotBe null
    is not equivalent to
    obj.shouldNotBeNull()
    . The former was used by Junie when
    obj
    was an iterator, and instead of just asserting on it not being
    null
    , it consumed all items of the iterator, making it unusable for future assertions. I think both should be equivalent since they read the same, and here in should.kt, we could have another check: if
    any
    is
    null
    . If yes, delegate it to
    any.shouldNotBeNull()
    . The same applies to
    shouldBe null
    . WDYT?
    a
    • 2
    • 5
  • k

    koufa

    08/28/2025, 8:24 AM
    Hello I updated my Kotlin Maven Project to Kotest 6. Using the Intellij Kotest Plugin I am getting the following issue when running the tests through the Context Menu and selecting a package:
    Copy code
    Exception in thread "main" java.lang.IllegalStateException: The specs arg must be provided
    	at io.kotest.engine.launcher.MainKt.main(main.kt:73)
    Is there anything I need to adapt so that this is supported?
    s
    • 2
    • 2
  • g

    Gopal S Akshintala

    08/28/2025, 3:24 PM
    How can I print the complete exception stacktrace of the code under test with Kotest? For example, it gives only the exception's stacktrace of Kotest, but not the code under test
    a
    • 2
    • 3