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

    solonovamax

    09/25/2025, 7:17 PM
    is there any way to have
    StableIdents.getStableIdentifier(Any?)
    be re-exposed so that it can be used? I was using it for the kotlin/js platform because I could not use
    withData()
    , as it would result in an error saying "Nested tests are not supported". my workaround for this was to instead use
    withClue()
    on the kotlin/js platform, doing this:
    Copy code
    actual fun FunSpecRootScope.testPrecomputed(
        context: String,
        precomputed: List<FuzzyTestData>,
        resultFunction: (String, String) -> Double,
    ) {
        context(context) {
            precomputed.forEach {
                withClue({ getStableIdentifier(it) }) {
                    resultFunction(it.first, it.second) shouldBe (it.result plusOrMinus DEFAULT_TOLERANCE)
                }
            }
        }
    }
    in kotest 6.0.0, this would instead be changed to use
    StableIdents.getStableIdentifier(it)
    , however this does not work because
    StableIdents
    is
    internal
    . I was told previously that nested tests would be present in 6.0, however they don't seem to be.
    a
    s
    • 3
    • 10
  • a

    Alfonso Ristorato

    09/28/2025, 10:12 AM
    Hello šŸ‘‹ as there was a clear intention in previous prs and threads to make
    withData
    generic, I went ahead and raised a PR on how I would attempt this. It's by no means supposed to be accepted, especially if the team was already working on this, but in case it helps with inspiration, or is considered good enough to merge, here it is šŸ˜„ https://github.com/kotest/kotest/pull/5113
    s
    • 2
    • 2
  • g

    Gautam Shorewala

    09/30/2025, 1:03 PM
    hi in kotest doc i saw that we can enable testDispatcher using this
    Copy code
    class TestDispatcherTest : FunSpec() {
       init {
          coroutineTestScope = true
          test("this test uses a test dispatcher") {
          }
          test("and so does this test!") {
          }
       }
    }
    now when i tried this in my code there the test crashes with
    Copy code
    Dispatchers.Main was accessed when the platform dispatcher was absent and the test dispatcher was unset. Please make sure that Dispatchers.setMain() is called before accessing Dispatchers.Main and that Dispatchers.Main is not accessed after Dispatchers.resetMain().
    This is a snippet of my test
    Copy code
    class EnterOtpComponentTest : FunSpec() {
    
        private lateinit var component: EnterOtpComponent
        private val mockOtpRepository = mockk<OtpRepository>(relaxed = true)
        private val testNumber = "1234567890"
    
        override val extensions: List<Extension> = listOf(
            KoinExtension(
                module = module {
                    single<OtpRepository> { mockOtpRepository }
                },
            )
        )
    
        init {
            coroutineTestScope = true
            mockkObject(Analytics)
            beforeTest {
                clearAllMocks()
            }
            testSendOtp()
            testOnOtpEnter()
        }
    is there anything i might have missed or doing wrong?
    s
    • 2
    • 2
  • a

    Alfonso Ristorato

    10/07/2025, 8:57 PM
    Hi šŸ‘‹ I don't know if for every pr you guys expect a message in slack, but if so šŸ˜… https://github.com/kotest/kotest/pull/5124
  • s

    stelios

    10/08/2025, 3:31 PM
    Hey everyone, we made an internal plugin for Android Studio that can ā€œfocusā€ a test in a
    BehaviorSpec
    . You select a
    Then
    , you type the shortcut and then all other Then’s are transformed to
    xThen
    . My question is can we publish it in the marketplace? In that case, our we allowed to use the term
    Kotest
    something like
    Focus test for Kotest
    or is it trademarked?
    s
    • 2
    • 3
  • g

    Giorgio Vespucci

    10/10/2025, 1:56 PM
    I started seeing some duplicate launch menu when want to run a ShouldSpec with the Kotest Plugin šŸ¤” Is there anything known to you? 🧵
    s
    s
    • 3
    • 5
  • g

    Geardaddie

    10/13/2025, 6:33 PM
    Hi all! Should I be able to run Kotest 6.x in a Gradle 9.x build without using JUnit runner and related libraries? It looks like I should, but the JVM examples all still use the JUnit runner and while I can run
    gradle kotest
    successfully I can’t run
    gradle build
    without it failing because it can’t find any tests. I’m sure I’ve got something configured wrong in Gradle, but I haven’t been able to find an example build script. kotest.io Setup | Kotest The Kotest test framework is supported on JVM, Javascript and Native.
    s
    • 2
    • 5
  • s

    sam

    10/15/2025, 5:19 AM
    6.0.4 has been published with a bunch of fixes.
  • s

    sam

    10/15/2025, 5:19 AM
    changelog here https://github.com/kotest/kotest/releases/tag/v6.0.4
    kodee happy 3
    šŸŽ‰ 8
  • e

    Emre

    10/19/2025, 10:49 PM
    I have been unable to report exceptions from the kotest intellij plugin lately because the options are grayed out in the reporter. JetBrains says it might be because
    The plugin doesn't register an error report submitter extension, so neither the "Report Exception" button nor the description area are enabled.
    https://youtrack.jetbrains.com/issue/IJPL-213335 Have you received any reports directly from the IDE lately? This is with 6.0.101-2025.2
  • d

    Dave

    10/22/2025, 12:06 PM
    should kotest multiplatform work for JS with es2015 compiler option?
  • b

    Bartek Milken

    10/22/2025, 1:06 PM
    Do you have maybe any data regarding how many people use
    IsolationMode.InstancePerLeaf
    ?
    😭 1
    l
    r
    • 3
    • 4
  • o

    Olaf Gottschalk

    10/23/2025, 8:18 AM
    Hi there! I just noticed something that really annoys and distracts me... when running "All tests..." from the context menu in IntelliJ clicking on the test source set, NOT ALL tests run, only the JUnit tests, but all spec tests from Kotest are completely ignored. In my project, I have a big mix of these two styles - due to historic reasons. Well, this USED to work just fine before, but today I noticed that this method to run all tests actually does not. When using grade build, everything just works fine, it is ONLY within IntelliJ... Any hints? What has changed in the past weeks? Kotest 6? New IntelliJ version? I have everything on the latest versions as of today! I got the Kotest plugin installed in IntelliJ. Thanks for any hints - especially how I can make sure this does not happen unnoticed!
    a
    l
    • 3
    • 6
  • r

    Rob Elliot

    10/24/2025, 10:18 AM
    Would someone be happy to do a quick sanity check on my usage of assertions in this snippet? I feel like either my
    satisfy
    matcher should already be in the assertions library, or else there's a better pattern to be used...
    Untitled.kt
    a
    • 2
    • 2
  • j

    J

    11/05/2025, 9:57 PM
    Hello all, I have a question about the spring extension especially the @DirtiesContext annotation. I've seen in previous conversations that this has been a problem. What is the current solution to achieve this behaviour in the easiest way possible? I checked the spring kotest docs, but this didn't really help me with that annotation. Maybe we could also add this to the docs as well?
    s
    • 2
    • 2
  • l

    Lukasz Kalnik

    11/07/2025, 1:58 PM
    I notice
    io.kotest.coroutines
    is not available anymore in 6.0. Where did it get migrated?
    s
    • 2
    • 2
  • l

    Lukasz Kalnik

    11/07/2025, 2:30 PM
    What has been
    listener()
    inside the Spec replaced with?
    s
    • 2
    • 2
  • l

    Lukasz Kalnik

    11/11/2025, 1:52 PM
    I wanted to re-implement
    InstancePerLeaf
    as an extension/listener. Do you have any hints how I could go about it? More details in 🧵
    • 1
    • 15
  • l

    Lukasz Kalnik

    11/11/2025, 2:53 PM
    Related: is there a guaranteed execution order of container/contained tests?
    a
    • 2
    • 25
  • e

    Emre

    11/11/2025, 5:16 PM
    kotest_filter_specs
    is not working for me. For example, when I run
    Copy code
    kotest_filter_specs='io.kotest.examples.jvm.SsnTest' gradle kotest
    in https://github.com/kotest/kotest-examples it runs them all. Did I make a mistake?
  • r

    Richard Schielek

    11/12/2025, 3:30 PM
    Since
    InstancePerLeaf
    is gone, I found myself restoring a fresh state before each leaf. Wouldn't it be nice to have something similar to the following? Does kotest maybe already have something like this? Or should all before* functions maybe return delegates?
    Copy code
    fun <T> ContainerScope.runningBeforeAny(initializer: () -> T): ReadOnlyProperty<Any?, T> {
        var value: T? = null
    
        beforeAny {
            value = initializer()
        }
    
        @Suppress("UNCHECKED_CAST")
        return ReadOnlyProperty { _, _ -> value as T }
    }
    
    
    object Spec : FreeSpec({
        "Given an empty list of numbers" - {
            val numbers by runningBeforeAny { mutableListOf<Int>() }
    
            "when adding one" - {
                beforeAny { numbers.add(1) }
    
                "the sum should be one" {
                    numbers.sum() shouldBe 1
                }
    
                "the size should be one" {
                    numbers shouldHaveSize 1
                }
    
                "when adding another one" - {
                    beforeAny { numbers.add(1) }
    
                    "the sum should be two" {
                        numbers.sum() shouldBe 2
                    }
    
                    "the size should be two" {
                        numbers shouldHaveSize 2
                    }
                }
            }
    
            "when leaving empty" - {
                "the sum should be 0" {
                    numbers.sum() shouldBe 0
                }
            }
        }
    })
    s
    • 2
    • 3
  • k

    koufa

    11/13/2025, 4:19 PM
    @sam Kotest 6 seems to not honour the ordering of the specs when defining a
    SpecExecutionOrderExtension
    . I am logging the return value of my
    override fun sort(specs: List<SpecRef>): List<SpecRef>
    but the specs executed are in another random order. Do I have to take care of something?
    s
    • 2
    • 6
  • k

    koufa

    11/14/2025, 1:10 PM
    Is it possible to use Spring from the Spring Extension outside of a Spec like in the BeforeProject listeners to be able to do some setup stuff using the Spring constructs like the Spring Webclient etc ?
    a
    • 2
    • 3
  • c

    CLOVIS

    11/15/2025, 10:51 AM
    Is Kotest compatible with Gradle 9.2?
    Copy code
    > Task :gradle:templates:template-app:jsBrowserTest FAILED
    java.lang.IllegalStateException: :gradle:templates:template-app:jsBrowserTest exited with errors (exit code: 1)
    >> Kotest
    - To infinity and beyond! (with tests)
    - Test plan has 1 specs
    
    1.  HelloWorldKotestTest
    
    >> All tests passed
    
    Specs:   1 passed, 0 failed, 1 total
    Tests:   0 passed, 0 failed, 0 ignored, 0 totalingwX64
    Time:    0s
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':gradle:templates:template-app:jsBrowserTest'.
    > There are test sources present and no filters are applied, but the test task did not discover any tests to execute. This is likely due to a misconfiguration. Please check your test configuration. If this is not a misconfiguration, this error can be disabled by setting the 'failOnNoDiscoveredTests' property to false.
    Kotest clearly finds the test, but I guess it doesn't report it correctly to Gradle?
    v
    • 2
    • 15
  • e

    eygraber

    11/18/2025, 6:20 AM
    It looks like there's an issue with
    mingw_x64
    . Gradle doesn't seem to be able to find the artifact for it, even though it exists.
    šŸ‘ 1
    s
    p
    • 3
    • 31
  • s

    sam

    11/30/2025, 10:18 PM
    Released 6.0.6 - if you were waiting for windows artifacts and/or koin, they're back. Changelog https://github.com/kotest/kotest/releases/tag/v6.0.6
    šŸŽ‰ 4
  • s

    sam

    12/01/2025, 6:58 AM
    Released 6.0.7 - same as 6.0.6 but with some missing mingw deps
    šŸ‘šŸ» 1
    šŸ‘ 2
    šŸ‘šŸ¼ 1
  • s

    Sebastian Schuberth

    12/01/2025, 10:43 AM
    I'm having trouble running Kotest with the Testcontainers extension on LInux with rootless Docker... I'm getting
    java.lang.IllegalStateException: Could not find a valid Docker environment. Please see logs and check configuration
    . Any hints how to fix this?
    n
    s
    • 3
    • 4
  • j

    Jakob Heher

    12/02/2025, 11:30 AM
    I'm having trouble with kotest's compiler assertions module. I have a should-not-compile test that fails (the code in question supposedly compiles); however if I take that exact code and paste it next to the test case, the whole thing fails to compile. No idea how to troubleshoot this. (Screenshot 1: the test fails because the code compiles. Screenshot 2: the same code fails to actually compile.)
    l
    s
    • 3
    • 20
  • e

    Emre

    12/04/2025, 3:08 PM
    kotest's intellij plugin crashed startup of a non-kotlin project. Should I create a ticket and/or try to fix it? The even bigger problem is that a likely misconfiguration in the plugin means I can't submit reports in the IDE; it won't let you type.
    Analysis is not allowed: Called in the EDT thread
    s
    • 2
    • 2