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

    Albilaga

    09/04/2025, 9:49 AM
    btw on kotest what is the correct way to call kotest to test in jvm (android)?
    Copy code
    ./gradlew kotestDebugUnitTest
    or
    Copy code
    ./gradlew test
    ?
  • m

    MarkRS

    09/05/2025, 12:03 PM
    Can't install 6. I'm trying to install KoTest 6.0.2, but AS says it can't find the required plugin. I seem to be on ...2025.1. The plugin dialogue doesn't offer to update me so I've downloaded ...2025.2 from the website, but when I try to install it I get the error message
    Plugin 'kotest' (version '6.0.101-2025.2') is not compatible with the current version of the IDE, because it requires build 252.23892 or newer but the current build is AI-251.26094.121
    However, I'm on Narwhal Feature Drop 3. Is this a case of AS lagging behind IntelliJ?
    v
    • 2
    • 10
  • p

    Piotr Krzemiński

    09/06/2025, 4:56 AM
    Hi, when updating from 6.0.0 to 6.0.1 or 6.0.2 (PR), I'm seeing an unspecified failure:
    Test running process exited unexpectedly.
    ,
    exited with errors (exit code: 1)
    . Build scan: https://scans.gradle.com/s/njfqnaca7haps. How do I debug this? Looks like a regression in kotest.
    • 1
    • 1
  • e

    Emre

    09/09/2025, 5:59 PM
    Why does
    gradle kotest
    exit code 0 on failed tests but
    gradle test
    correctly returns 1? Is there a setting for this? Tested on kotest 6.0.2, gradle 9.0.0.
    s
    • 2
    • 39
  • e

    Emre

    09/10/2025, 1:49 AM
    Double clicking to run a single test from the IntelliJ plugin does not work; the selected test is also filtered out. The filtering relies on the deprecated testpath parameter. Could that be why?
    s
    • 2
    • 2
  • e

    Edoardo Luppi

    09/10/2025, 2:24 PM
    I can't for the life of me run a single test case under K/JS. Should
    --tests
    work?
    v
    m
    • 3
    • 12
  • j

    Jonathan Lennox

    09/10/2025, 6:40 PM
    When I update my Kotlin version from 2.0.0 to 2.2.0, I'm seeing kotest tests fail with
    Copy code
    NoClassDefFound kotlin/coroutines/jvm/internal/SpillingKt
    Does kotest 5.9.1 work with Kotlin 2.2.0, or do I need to update to 6.0.3?
    s
    • 2
    • 4
  • e

    Edgar

    09/11/2025, 9:26 AM
    On Android Studio, with version 6.0.3, launching a single test with the play button, the test fail with:
    Copy code
    Testing started at 11:21 ...
    java.lang.NoClassDefFoundError: kotlin/reflect/full/KClasses
    	at io.kotest.common.reflection.JvmReflection.supers(reflection.kt:43)
    	at io.kotest.common.reflection.JvmReflection.annotations(reflection.kt:34)
    	at io.kotest.common.reflection.JvmReflection.annotations(reflection.kt:25)
    	at io.kotest.engine.concurrency.ConcurrencyKt.isIsolate(concurrency.kt:30)
    	at io.kotest.engine.TestSuiteScheduler.schedule(TestSuiteScheduler.kt:39)
    	at io.kotest.engine.TestEngine$execute$innerExecute$1.invoke(TestEngine.kt:66)
    	at ...
    Caused by: java.lang.ClassNotFoundException: kotlin.reflect.full.KClasses
    	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
    	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
    	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
    	... 49 more
    
    kotlin/reflect/full/KClasses
    However, running all the tests in the class, works perfectly. Is there a way to solve this? 🙏
    s
    • 2
    • 1
  • o

    Olaf Gottschalk

    09/16/2025, 6:48 AM
    Hey Kotesters! I struggle a lot with the different concepts of the two functions:
    Copy code
    shouldHaveSingleElement(element)
    shouldHaveSingleElement { block... }
    Every time I want to use them, I have to go back to documentation and/or code to see for myself that the first one, which takes an element actually does assert that the collection contains just a single element and the latter, which takes a predicate, does not do that, instead it only checks the collection to contain one single element that passes the predicate, but could potentially contain many more elements. The documentation piece I found here looks like this:
    collection.shouldHaveSingleElement(element)	Asserts that the collection only contains a single element and that that element is the given one.
    collection.shouldHaveSingleElement { block }	Asserts that the collection contains a single element by a given predicate.
    This is very error prone as most of the time my assumption is I need a check that the collection contains a single element and the next step is only to either be able to provide the element for equals test OR a predicate to check some aspects of the element - but never I expect different behaviour in the main aspect of the function. Can somebody explain to my why we have this and whether it really is intentionally? Maybe I don't see it... Thanks!
    k
    a
    • 3
    • 10
  • s

    Shervin

    09/16/2025, 8:45 AM
    kotest-framework-api-jvm
    is not generated for last few releases, https://repo.maven.apache.org/maven2/io/kotest/kotest-framework-api-jvm/ latest generated is 6.0.0.M1 where we have higher versions in `assertions-core`like 6.0.3 is this expected ?
    s
    • 2
    • 2
  • s

    Shervin

    09/17/2025, 3:03 PM
    Does anyone know what is the root cause of my test (
    BehaviorSpec
    ), not running, when
    kotest-extensions-roboelectric
    dependency is added to the module ? Im using 6.0.3 and 0.5.0 versions respectively. I get the following error:
    'io.kotest.engine.tags.TagExpression io.kotest.core.extensions.TagExtension.tags()'
    java.lang.NoSuchMethodError: 'io.kotest.engine.tags.TagExpression io.kotest.core.extensions.TagExtension.tags()'
    at io.kotest.engine.tags.TagExpressionBuilder.build(runtime.kt:15)
    at io.kotest.engine.spec.interceptor.ref.enabled.TagsInterceptor.intercept-0E7RQCE(TagsInterceptor.kt:28)
    at io.kotest.engine.spec.interceptor.SpecRefInterceptorPipeline$execute$3$1.invoke-gIAlu-s(SpecRefInterceptorPipeline.kt:49)
    at io.kotest.engine.spec.interceptor.ref.DescriptorFilterSpecRefInterceptor.intercept-0E7RQCE(DescriptorFilterSpecRefInterceptor.kt:41)
    at io.kotest.engine.spec.interceptor.SpecRefInterceptorPipeline$execute$3$1.invoke-gIAlu-s(SpecRefInterceptorPipeline.kt:49)
    at io.kotest.engine.spec.interceptor.ref.ApplyExtensionsInterceptor.intercept-0E7RQCE(ApplyExtensionsInterceptor.kt:36)
    at io.kotest.engine.spec.interceptor.SpecRefInterceptorPipeline$execute$3$1.invoke-gIAlu-s(SpecRefInterceptorPipeline.kt:49)
    at io.kotest.engine.spec.interceptor.ref.enabled.IgnoredSpecInterceptor.intercept-0E7RQCE(IgnoredSpecInterceptor.kt:47)
    at io.kotest.engine.spec.interceptor.SpecRefInterceptorPipeline$execute$3$1.invoke-gIAlu-s(SpecRefInterceptorPipeline.kt:49)
    at io.kotest.engine.spec.interceptor.ref.enabled.DisabledIfInterceptor.intercept-0E7RQCE(DisabledIfInterceptor.kt:46)
    at io.kotest.engine.spec.interceptor.SpecRefInterceptorPipeline$execute$3$1.invoke-gIAlu-s(SpecRefInterceptorPipeline.kt:49)
    at io.kotest.engine.spec.interceptor.ref.enabled.EnabledIfInterceptor.intercept-0E7RQCE(EnabledIfInterceptor.kt:41)
    at io.kotest.engine.spec.interceptor.SpecRefInterceptorPipeline$execute$3$1.invoke-gIAlu-s(SpecRefInterceptorPipeline.kt:49)
    at io.kotest.engine.spec.interceptor.ref.enabled.RequiresPlatformInterceptor.intercept-0E7RQCE(RequiresPlatformInterceptor.kt:25)
    at io.kotest.engine.spec.interceptor.SpecRefInterceptorPipeline$execute$3$1.invoke-gIAlu-s(SpecRefInterceptorPipeline.kt:49)
    at io.kotest.engine.spec.ClassVisibilitySpecRefInterceptor.intercept-0E7RQCE(ClassVisibilitySpecRefInterceptor.kt:29)
    at io.kotest.engine.spec.interceptor.SpecRefInterceptorPipeline$execute$3$1.invoke-gIAlu-s(SpecRefInterceptorPipeline.kt:49)
    at io.kotest.engine.spec.interceptor.SpecRefInterceptorPipeline.execute-0E7RQCE(SpecRefInterceptorPipeline.kt:52)
    at io.kotest.engine.spec.execution.SpecRefExecutor.execute(SpecRefExecutor.kt:45)
    at io.kotest.engine.TestSuiteScheduler.executeIfNotFailedFast(TestSuiteScheduler.kt:97)
    at io.kotest.engine.TestSuiteScheduler.access$executeIfNotFailedFast(TestSuiteScheduler.kt:29)
    at io.kotest.engine.TestSuiteScheduler$schedule$11$1$2.invokeSuspend(TestSuiteScheduler.kt:77)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
    at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:263)
    at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:94)
    at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:70)
    at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
    at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:48)
    at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
    at io.kotest.engine.RunBlocking_jvmKt.runBlocking(runBlocking.jvm.kt:3)
    at io.kotest.engine.TestEngineLauncher.launch(TestEngineLauncher.kt:206)
    at io.kotest.runner.junit.platform.KotestJunitPlatformTestEngine.execute(KotestJunitPlatformTestEngine.kt:74)
    at io.kotest.runner.junit.platform.KotestJunitPlatformTestEngine.execute(KotestJunitPlatformTestEngine.kt:47)
    s
    • 2
    • 5
  • e

    Emre

    09/18/2025, 4:24 PM
    I ran
    gradle kotest
    and it triggered
    buildOpenApi
    . Does anyone know why?
    Copy code
    [kotest] $ gradle kotest
    
    > Task :buildOpenApi
    Ktor's OpenAPI generation is ** experimental **
    - It may be incompatible with Kotlin versions outside 2.2.20
    - Behavior will likely change in future releases
    - Please report any issues at <https://youtrack.jetbrains.com/newIssue?project=KTOR>
    <==========---> 76% EXECUTING [7s]
    gradle test
    does not do this.
    v
    • 2
    • 1
  • p

    Piotr Krzemiński

    09/19/2025, 8:51 AM
    a somewhat confusing output:
    Copy code
    110.  IGNORED
    - emit unicode OK
    - escape unicode OK
    I see two problems here: 1. Instead of a name of the test file/module, there are two whitespaces (as if the name was omitted) and just
    IGNORED
    . 2. Each test case gets a green
    OK
    , but the whole test file/module is
    IGNORED
    . It's inconsistent because it both looks as if the whole test file/module was ignored, yet individual test cases are executed
    s
    • 2
    • 4
  • e

    Emiel Bon

    09/19/2025, 10:34 AM
    Hi, quick question, I saw some discussions that there was a plan to include a
    JunitXmlReporter
    implementation for non-JVM targets for 6.0.0. I guess it didn't make it in, is it still on the radar?
    s
    s
    • 3
    • 12
  • s

    solonovamax

    09/22/2025, 8:20 AM
    is there any reasonable-ish way to pass environment variables to kotlin/multiplatform test runs (native & js)? I want to configure the junit xml reporter, html reporter, and allure reporter to all output in the correct directories for a given test (for example using
    build/test-results/jvmTest
    for the
    jvmTest
    task,
    build/test-results/linuxX64Test
    for the
    linuxX64Test
    task, etc. from what I can tell there doesn't really seem to be any good solution for this...
  • s

    Sebastian Schuberth

    09/23/2025, 8:48 AM
    Is there a simpler syntax than
    Arb.bind<File>().single()
    to create a single arbitrary file? Specifically, I'm looking for something like
    inline fun <reified T> arb(): T = Arb.bind<T>().single()
    , but that does not compile.
    l
    • 2
    • 2
  • 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
    • 1
  • 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
    • 2
    • 3
  • 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