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

    Shervin

    02/17/2025, 10:57 AM
    Hey! asked here, but for better visibility I'm going to ask in details here as well: Is there any documentation for migrating to v6 after changes done to Isolation mode?
    s
    • 2
    • 1
  • d

    dirk.dittert

    02/17/2025, 2:27 PM
    I am wondering about the best approach to deal with comparing multi-line strings to expected values. I ran into the following setup a couple of times now:
    Copy code
    val data = readSomeData() // reads a file from /src/test/resources
    val actual = mangle(data)
    actual shouldBe """
        line 1
        line 2
        """.trimIndent()
    The problem is that line separators can be different between the file and Kotlin multiline strings. How to deal with that in the most convenient way possible?
    k
    e
    a
    • 4
    • 8
  • d

    dirk.dittert

    02/19/2025, 10:10 AM
    I have been using KoTest quite extensively over the last couple of months and do like it as a testing framework. There is one thing that is driving me crazy because it is constantly breaking my development flow. That is, that I can't just keep running Specs. IntelliJ shows "Current File" and Run/Debug gets disables. Sometimes when I delete the run configuration it will work a couple more times but will eventually break again. This is an absolute killer for productivity as I keep running my tests constantly while my code is evolving. I believe that this is the bug that was already reported by Geoffry: https://github.com/kotest/kotest/issues/4646
    👍 1
    👍🏼 1
    l
    s
    • 3
    • 25
  • s

    Shervin

    02/19/2025, 12:31 PM
    Hey all! 1. Do we know when does v6 go live? 2. About the upcoming changes in Isolation mode, do we expect huge breaking changes? Our app is heavily using 'per leaf' mode. I want to estimate how much of 'tech debt' will be added to our back log Thanks in advance!
    d
    s
    +3
    • 6
    • 51
  • a

    abendt

    02/20/2025, 5:05 PM
    hi folks, I ran into a small issue while using Kotest and Testcontainers with the kotest-extensions-testcontainers today (details in 🧵).
    • 1
    • 2
  • j

    Justin Tullgren

    02/25/2025, 12:40 PM
    Hi. Does anyone know how to correctly set up kotest for a KMP project so that kotest picks up specs in the
    androidUnitTest
    source folder. Set up described here https://www.jetbrains.com/help/kotlin-multiplatform-dev/multiplatform-run-tests.html#for-android. Right now kotest doesn’t notice those tests when it does a scan so no tests are run but it does pick up the commonTest specs.
    • 1
    • 1
  • k

    Klitos Kyriacou

    02/25/2025, 4:26 PM
    What's the best way to assert that two ByteArrays are the same (as per
    contentEquals
    )?
    l
    a
    • 3
    • 7
  • k

    Kirill Zhukov

    03/14/2025, 7:07 PM
    Am I misunderstanding how clues supposed to work? Tried
    asClue
    and
    withClue
    but I'm not seeing the clue included in a stacktrace 🧵
    e
    a
    • 3
    • 14
  • h

    huehnerlady

    03/21/2025, 5:46 AM
    HI, I use the kotest plugin and for a few week I have the problem now that `CMD`+`SHIFT`+`T` runs into an exception:
    Copy code
    org.jetbrains.kotlin.analysis.api.impl.base.sessions.ProhibitedAnalysisException: Analysis is not allowed: Called in the EDT thread.
    	at org.jetbrains.kotlin.analysis.api.impl.base.sessions.KaBaseSessionProvider.beforeEnteringAnalysis(KaBaseSessionProvider.kt:54)
    	at org.jetbrains.kotlin.analysis.api.impl.base.sessions.KaBaseSessionProvider.beforeEnteringAnalysis(KaBaseSessionProvider.kt:45)
    	at io.kotest.plugin.intellij.psi.SuperClassesKt.getAllSuperClasses(superClasses.kt:48)
    	at io.kotest.plugin.intellij.psi.SpecsKt.specStyle(specs.kt:52)
    	at io.kotest.plugin.intellij.psi.SpecsKt.isSpec(specs.kt:31)
    	at io.kotest.plugin.intellij.psi.SpecsKt.isContainedInSpec(specs.kt:76)
    	at io.kotest.plugin.intellij.KotestTestFinder.isTest(KotestTestFinder.kt:45)
    	at com.intellij.testIntegration.TestFinderHelper.isTest(TestFinderHelper.java:48)
    	at com.intellij.testIntegration.GotoTestOrCodeHandler.getSourceAndTargetElements(GotoTestOrCodeHandler.java:50)
    	at com.intellij.codeInsight.navigation.GotoTargetHandler.invoke(GotoTargetHandler.java:72)
    	at com.intellij.codeInsight.actions.CodeInsightAction.lambda$actionPerformedImpl$0(CodeInsightAction.java:73)
    	at com.intellij.codeInsight.actions.CodeInsightAction.lambda$actionPerformedImpl$1(CodeInsightAction.java:79)
    	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:226)
    	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:178)
    	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:159)
    	at com.intellij.codeInsight.actions.CodeInsightAction.actionPerformedImpl(CodeInsightAction.java:70)
    	at com.intellij.codeInsight.actions.CodeInsightAction.actionPerformed(CodeInsightAction.java:41)
    	at com.intellij.openapi.actionSystem.ex.ActionUtil.doPerformActionOrShowPopup(ActionUtil.kt:345)
    	at com.intellij.openapi.keymap.impl.ActionProcessor.performAction(ActionProcessor.java:32)
    	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$actionProcessor$1.performAction(IdeKeyEventDispatcher.kt:496)
    	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcherKt.doPerformActionInner$lambda$4$lambda$3(IdeKeyEventDispatcher.kt:845)
    	at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:106)
    	at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:95)
    	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcherKt.doPerformActionInner$lambda$4(IdeKeyEventDispatcher.kt:845)
    	at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.performWithActionCallbacks(ActionManagerImpl.kt:1164)
    	at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.kt:362)
    	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcherKt.doPerformActionInner(IdeKeyEventDispatcher.kt:843)
    	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcherKt.access$doPerformActionInner(IdeKeyEventDispatcher.kt:1)
    	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction$intellij_platform_ide_impl(IdeKeyEventDispatcher.kt:572)
    	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.kt:509)
    	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processActionOrWaitSecondStroke(IdeKeyEventDispatcher.kt:448)
    	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.inInitState(IdeKeyEventDispatcher.kt:441)
    	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.kt:303)
    	at com.intellij.ide.IdeEventQueue.dispatchKeyEvent(IdeEventQueue.kt:620)
    	at com.intellij.ide.IdeEventQueue._dispatchEvent$lambda$15(IdeEventQueue.kt:582)
    	at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteIntentReadAction(AnyThreadWriteThreadingSupport.kt:84)
    	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:582)
    	at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:73)
    	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1$1.compute(IdeEventQueue.kt:357)
    	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1$1.compute(IdeEventQueue.kt:356)
    	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:843)
    	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.invoke(IdeEventQueue.kt:356)
    	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.invoke(IdeEventQueue.kt:351)
    	at com.intellij.ide.IdeEventQueueKt$performActivity$runnableWithWIL$1.invoke$lambda$0(IdeEventQueue.kt:1035)
    	at com.intellij.openapi.application.WriteIntentReadAction.lambda$run$0(WriteIntentReadAction.java:24)
    	at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteIntentReadAction(AnyThreadWriteThreadingSupport.kt:84)
    	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteIntentReadAction(ApplicationImpl.java:910)
    	at com.intellij.openapi.application.WriteIntentReadAction.compute(WriteIntentReadAction.java:55)
    	at com.intellij.openapi.application.WriteIntentReadAction.run(WriteIntentReadAction.java:23)
    	at com.intellij.ide.IdeEventQueueKt$performActivity$runnableWithWIL$1.invoke(IdeEventQueue.kt:1035)
    	at com.intellij.ide.IdeEventQueueKt$performActivity$runnableWithWIL$1.invoke(IdeEventQueue.kt:1035)
    	at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:1036)
    	at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:114)
    	at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:1036)
    	at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$10(IdeEventQueue.kt:351)
    	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:397)
    	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
    	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
    I currently use intellij 2024.2.5 where it work last. I also tried uninstall and reinstall the plugin, but that doesn't help Currently I installed the latest version - 1.3.92-2024.2.2 Anything what I can try?
  • p

    phldavies

    03/21/2025, 3:29 PM
    did kotest-assertions-ktor not get released as part of 6.0.0.M2?
    e
    s
    • 3
    • 6
  • r

    Rob Elliot

    03/28/2025, 3:54 PM
    Hi, I'be alighted on this pattern for sharing code between specs:
    Copy code
    import io.kotest.core.spec.style.StringSpec
    import io.kotest.matchers.shouldBe
    
    @Suppress("UNCHECKED_CAST")
    abstract class AbstractSpec(
      body: AbstractSpec.() -> Unit,
    ) : StringSpec(body as StringSpec.() -> Unit) {
      fun shared() {  }
      val sharedProperty = "foo"
    }
    
    class ConcreteSpec : AbstractSpec({
      "some test" {
        shared()
        sharedProperty shouldBe "foo"
      }
    })
    That unchecked cast bothers me, and suggests to me that there is probably a better way... could someone point me at the docs I've missed?
    l
    s
    t
    • 4
    • 14
  • s

    Sergi Aguilar

    03/31/2025, 8:52 AM
    Hello has anyone used kotest to unit test ktor routes? I can't find too much documentation/examples about it
    s
    e
    • 3
    • 4
  • s

    sam

    03/31/2025, 7:58 PM
    I release 6.0.0.M3 if anyone wants to give it a go and feedback
    🙌 2
    kotest intensifies 4
    🙌🏼 1
  • e

    Emre

    03/31/2025, 9:44 PM
    @sam Please could you add a changelog to the intellij plugin, or use releases/tags? The versioning scheme based on the GITHUB_RUN_NUMBER secret inscrutable; there is no way to check what commit it corresponds to.
    s
    • 2
    • 2
  • d

    dirk.dittert

    04/01/2025, 1:36 PM
    Sorry, I must be a bit clumsy and miss something obvious.
    Copy code
    val subject = intArrayOf()
    val expected = intArrayOf()
    subject shouldBeEqual expected
    This fails because what I really intended to do was to use
    contentEquals()
    on the arrays. I don't seem to find a matcher to do just that, though?
    v
    • 2
    • 14
  • d

    dirk.dittert

    04/01/2025, 2:01 PM
    I see this regularly (but not always) when I run my tests:
    Copy code
    [0.631s][error][attach] failure (232) writing result of operation jcmd to pipe \\.\pipe\javatool-558031551
    Is this caused by KoTest?
    l
    • 2
    • 4
  • w

    wellingtoncosta

    04/01/2025, 4:33 PM
    Hey there, I'm trying to run a simple test suite using Kotest in a KMP module, but it doesn't seem to work, neither via terminal by running the
    check
    task or by hitting the play button.
    Copy code
    // libs.versions.toml
    kotest = [
        "kotest-framework-engine",
        "kotest-assertions",
        "kotest-property",
    ]
    
    // build.gradle.kts
    commonTest {
        dependencies {
            implementation(kotlin("test-common"))
            implementation(kotlin("test-annotations-common"))
    
            implementation(libs.kotlinx.coroutines.test)
            implementation(libs.bundles.kotest)
            implementation(libs.koin.test)
            implementation(libs.turbine)
        }
    }
    
    // in commonTest source set
    class KotestSampleTest : BehaviorSpec() {
        init {
            Given("2 + 2") {
                Then("it must be 4") {
                    2 + 2 shouldBeEqual 4
                }
            }
        }
    }
  • t

    Tasuku Nakagawa

    04/02/2025, 7:03 AM
    hi, i wonder is there any alternatives of
    InstancePerLeaf
    on Kotest 6.0.0 (M3). i want to instantiate test cases for each
    it
    blocks of
    DescribeSpec
    l
    s
    • 3
    • 5
  • d

    dirk.dittert

    04/04/2025, 1:39 PM
    I see failure stack traces with line numbers that are not in my file. That is, it says that it fails in
    SomeModelSpeckt:150
    when there are only 120 lines in that file. That only seems to happen when I use
    assertSoftly
    . Does anyone know what is going on here?
    e
    • 2
    • 2
  • f

    Fergus Hewson

    04/10/2025, 7:32 PM
    Hey, Trying to get powerAssert working with kotest matchers and am getting
    Copy code
    Unable to find overload of function io.kotest.matchers.shouldBe for power-assert transformation callable as:
     - io.kotest.matchers.shouldBe(String)
     - io.kotest.matchers.shouldBe(() -> String)
     - io.kotest.matchers.shouldBe(U of io.kotest.matchers.shouldBe?, String)
     - io.kotest.matchers.shouldBe(U of io.kotest.matchers.shouldBe?, () -> String)
    Kotest "6.0.0.M3" Kotlin "2.1.20" Any ideas?
    • 1
    • 1
  • m

    Matteo Mirk

    04/15/2025, 7:51 AM
    Excuse me, what happened to the documentation? There's lots of information missing, and the left-side navigation bar is gone. 🤔
    l
    a
    e
    • 4
    • 12
  • g

    Giorgio Vespucci

    04/17/2025, 10:36 AM
    Hello, is a version of the Kotest Plugin arriving for
    IDEA 2025.1
    ? My Kotest Plugin
    1.3.92-2024.3.1
    is preventing me from navigating to tests by using
    Navigate -> Test
    . See the attached screenshot.
    s
    e
    • 3
    • 21
  • g

    Giorgio Vespucci

    04/18/2025, 12:31 PM
    What's the easiest way of debugging Kotest internals? Are there some switches to enable
    debug
    level of logging to see what "it's doing"? I'm affected in my work project by a behavior that HANGS A LOT before starting to execute the tests. I cannot upgrade from V5.6.x to v5.9.x due to this. I only see an infinite series of
    Copy code
    Warning: Kotest autoscan is enabled. This means Kotest will scan the classpath for extensions that are annotated with @AutoScan. To avoid this startup cost, disable autoscan by setting the system property 'kotest.framework.classpath.scanning.autoscan.disable=true'. In 6.0 this value will default to true. For further details see <https://kotest.io/docs/next/framework/project-config.html#runtime-detection>
    Setting the mentioned property to
    true
    doesn't help. Thank You CC @Matteo Mirk
    m
    s
    • 3
    • 6
  • e

    Emre

    04/24/2025, 1:07 PM
    Why does TestClock implement
    java.time.Clock
    rather than
    kotlinx.datetime.Clock
    ?
    k
    • 2
    • 1
  • s

    Sebastian Schuberth

    04/24/2025, 1:29 PM
    I'd like to use Kotest with JUnit's Console Launcher, but my tests do not seem to be discovered. Has anyone made that working yet?
    e
    s
    a
    • 4
    • 14
  • p

    phldavies

    04/24/2025, 2:57 PM
    Any likelihood of a 6.0.0.M4 release soon? The test-containers stackoverflows are hard to work around
    s
    • 2
    • 1
  • m

    MarkRS

    04/30/2025, 8:26 AM
    Engine Exception That's about it! My test won't run, giving this error and the name of the test it was running and that's it, no other indication. How do I go about getting more information?
    e
    • 2
    • 4
  • j

    James Eschner

    05/05/2025, 5:54 PM
    Hello, is there a timeline for a full 6.0 release? *Not a contribution
    s
    s
    s
    • 4
    • 12
  • b

    Benoît Liessens

    05/07/2025, 7:03 AM
    The latest 6.0.0 milestone releases do no longer provide
    withEnvironment
    . Is there a replacement? Thanks
    👀 3
  • b

    Bernd Prünster

    05/08/2025, 5:40 PM
    Hi there! Dummy question: what is the state of the new compiler plugin (see #4870 #4871)? The more I keep digging into what Transformer does, the more issues crop up. Rather than spamming GitHub: Is that new multiplatform compiler plugin supposed to be in a working state as of now or was it intentionally not used?
    • 1
    • 1