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

    Sebastian Schuberth

    06/11/2025, 2:32 PM
    I'm surprised that https://kotest.io/docs/framework/project-config.html#parallelism does not document how it plays together with https://docs.gradle.org/current/userguide/performance.html#a_run_tests_in_parallel. Any hints on that?
    a
    • 2
    • 3
  • k

    Klitos Kyriacou

    06/11/2025, 3:44 PM
    I was thinking of doing something like this:
    Copy code
    val result: MyResultType
    mockkObject(SomeObject) {
        every { SomeObject.foo() } returns "bar"
        result = callUnitUnderTest()
    }
    
    result.a shouldBe 1
    result.b shouldBe 2
    The idea was to keep the time the object is mocked to a minimum. The object doesn't have to remain mocked while I'm doing the assertions. Unfortunately, the Kotlin compiler gives an error saying
    result
    is reassigned inside the lambda and uninitialized outside the lambda. This is because it doesn't know that the lambda is guaranteed to be called exactly once. This can be fixed by the use of contracts. Is there any chance it can be done in a future release?
    a
    • 2
    • 2
  • p

    phldavies

    06/11/2025, 7:20 PM
    Is there any reason not to bump ktor dependency for kotest-assertions-ktor to 3.x?
    a
    • 2
    • 3
  • j

    Justin Tullgren

    06/13/2025, 3:00 PM
    Hello. We are in the middle of upgrading to Kotlin 2.1 and we ran into an issue with kotest 5.9 that forced us to try the 6.0 milestones. However, now I am seeing that IsolationMode.InstancePerLeaf has been removed. Is this expected? I couldn’t find anything in the changelogs. If its expected is there a “rough draft” of the guide for migration?
    s
    • 2
    • 3
  • s

    Scott Fedorov

    06/16/2025, 6:29 PM
    If you have time, please consider upvoting this issue to get Junie to be able to run the Kotest tests it writes. That's apparently too much to ask for 🤦‍♂️ https://youtrack.jetbrains.com/issue/JUNIE-239/Add-support-for-Kotest Thanks @Emre for making.
    ➕ 2
    ✅ 1
    s
    c
    • 3
    • 9
  • r

    Rob Elliot

    06/18/2025, 8:38 AM
    I have some flaky tests. With JUnit I just use IntelliJ's runnier to repeat until failure. With Spock there's
    @RepeatUntilFailure
    . What's the Kotest equivalent?
    c
    a
    • 3
    • 4
  • b

    Benoît Liessens

    06/20/2025, 6:36 AM
    Been using Kotest for some time now and gotten pretty fluent at writing Kotest extensions and Matchers. Just this week I wrote slightly more complex Matcher that I needed to use in both a positive (
    shouldBe ….
    ) and negative
    (shouldNotBe …
    ) which made me realise every Kotest matcher is `invert()`able! To my surprise neither Hamcrest nor AssertJ matcher have such capability. Really nice! 👏
    kotest intensifies 2
  • b

    Bernd Prünster

    06/21/2025, 6:35 AM
    Hi! We're blocked by https://github.com/kotest/kotest/issues/4895, as we really need to have tests running on all targets with the latest Kotlin EAP. Does anyone familiar with the Kotest Codebase have any pointers as to why only the JVM runner ist currently working?
    c
    s
    • 3
    • 40
  • a

    Alex Kuznetsov

    06/25/2025, 6:13 PM
    can someone answer this issue https://github.com/kotest/kotest/issues/4905
  • m

    MarkRS

    06/27/2025, 3:02 PM
    withData can't cope with a float value in its name function? I have a withData structure like this
    val someFloats = listOf(1F, 2F, 4.2F)
    withData<Float>({"Testing $someFloat"}, someFloats) { someFloat -> &tc
    and the compiler complains about $someFloat in the name function (with our without .toString()). Full(er) disclosure, it's the seventh nested withData, but without the name function it works, and I've tried reducing the number of nests and it still complains. Bug?
    p
    • 2
    • 1
  • h

    hantsy

    06/29/2025, 1:49 AM
    I tried to use Kotest with Spring, but I only found the
    AnnotationSpec
    working well.
    Copy code
    @Import(TestcontainersConfiguration::class)
    @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
    class DemoApplicationAnnotationSpec : AnnotationSpec() {
        @LocalServerPort
        private var port: Int = 8080
        lateinit var client: WebClient
    
        @BeforeEach
        fun setUp() {
            client = WebClient.create("<http://localhost>:$port")
        }
    
        @Test
        fun `get all posts`() {
            client.get()
                .uri("/posts")
                .accept(MediaType.APPLICATION_JSON)
                .exchangeToFlux {
                    assertThat(it.statusCode()).isEqualTo(HttpStatus.OK)
                    it.bodyToFlux(Post::class.java)
                }
                .test()
                .expectNextCount(2)
                .verifyComplete()
        }
    }
    How to convert this to use
    StringSpec
    FuncSpec
    ,etc., especially I do not know where to use the Spring special annotation to inject beans, such as
    LocalServerPort
    ,
    MockkBean
    , etc. I have tried to use LocalServerPort in the test class body, but it can not be accessed in the test block.
    Copy code
    xxxStringSpec:StringSpec({
       //1. @LocalServerPort is NOT allowed here
       //2. The port injected in the class body(below) cannot be accessed here.
    
    }){
        @LocalServerPort
        private var port: Int = 8080
    }
    e
    • 2
    • 16
  • a

    Alexander Ioffe

    06/30/2025, 6:57 AM
    I'm getting a strange "module-missing" error with Kotest M4. Is this something that still needs to be published?
    Copy code
    Could not find io.kotest:kotest-framework-multiplatform-plugin-embeddable-compiler:6.0.0.M4
  • b

    Bernd Prünster

    06/30/2025, 8:29 AM
    known issue. use latest 6.0.0-SNAPSHOT
  • a

    Alexander Ioffe

    06/30/2025, 3:37 PM
    Is there a known issue with M3 on compileTestKotlinIosArm64 in 2.2.0? I'm getting:
    Copy code
    e: java.lang.NoSuchMethodError: 'org.jetbrains.kotlin.ir.expressions.IrConstructorCall org.jetbrains.kotlin.ir.builders.ExpressionHelpersKt.irCall(org.jetbrains.kotlin.ir.builders.IrBuilderWithScope, org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol)'
  • a

    Alexander Ioffe

    06/30/2025, 5:22 PM
    (ah, looks like it is: https://github.com/kotest/kotest/issues/4870)
  • a

    Alexander Ioffe

    06/30/2025, 5:49 PM
    @Bernd Prünster Now that s01 is gone, how do I actually get a hold of the snapshot version of kotest?
    maven { url = uri("<https://central.sonatype.com/repository/maven-snapshots>") }
    doesn't seem to do anything.
  • b

    Bernd Prünster

    06/30/2025, 6:32 PM
    Kotest Team needs to publish to the new endpoint
  • a

    Alexander Ioffe

    06/30/2025, 8:19 PM
    That can be a giant headache, make sure you don't make the same mistakes I made: https://kotlinlang.slack.com/archives/C2YH04E3S/p1750990424590899?thread_ts=1745056051.782729&amp;cid=C2YH04E3S
  • a

    Alexander Ioffe

    06/30/2025, 8:20 PM
    (everything I said there probably also applies to the central.sonatype.com/repository/maven-snapshots repo as well)
  • e

    Emil Kantis

    06/30/2025, 9:15 PM
    @Alexander Ioffe if you have time to create an issue and reference your learnings, I'd appreciate it.
  • a

    Alexander Ioffe

    06/30/2025, 9:16 PM
    An issue for moving to the new snapshot repo or for migrating away from sonatype-s01 in general?
  • e

    Emil Kantis

    06/30/2025, 9:19 PM
    The former, I think..? Is it relevant to migrate away from s01?
  • a

    Alexander Ioffe

    06/30/2025, 9:25 PM
    s01.oss.sonatype.org is being decommed as we speak, same with oss.sonatype.org
  • a

    Alexander Ioffe

    06/30/2025, 9:30 PM
    You need to move to move both snapshots and releases. The former to ossrh-staging-api.central.sonatype.com (or have a look at @mbonnin's nmcp) and the latter to central.sonatype.com/repository/maven-snapshots.
    👍 1
  • e

    Emil Kantis

    06/30/2025, 9:32 PM
    Right. Sounds to me like that warrants a ticket per task, but I'll let you decide. 😉
    👍 1
  • a

    Alex Kuznetsov

    07/01/2025, 5:56 PM
    🧵 please ^^^
    👍🏾 1
    sorry 1
  • o

    Olaf Gottschalk

    07/03/2025, 12:51 PM
    So, I got a question regarding the Kotest plugin for IntelliJ! I really, really LOVE to use Kotest over JUnit... but there's a few annoyances where I would like to know if this is an unsolvable problem or a bug... when tests fail, I like to quickly jump to them by clicking on the name in the runner panel... but for Kotest tests that "link" is not there as it is for JUnit tests... because of that, it is really, really tedious to find the source code of the failing test. Any plans to fix this? Thx!
    💯 4
    l
    e
    s
    • 4
    • 5
  • p

    phldavies

    07/07/2025, 3:02 PM
    Is it worth considering making
    should(matcher: (T) -> Unit)
    inline as part of 6.x? Possible the same for
    shouldNotBeNull
    a
    k
    s
    • 4
    • 20
  • e

    Emil Kantis

    07/08/2025, 2:46 PM
    Kotest 6.0.0.M5 is out. https://github.com/kotest/kotest/releases/tag/v6.0.0.M5 This also marks our first release to the new Maven Central. If you notice any artifacts missing or other oddities related to publications feel free to ping me directly.
    kotest intensifies 8
    🎉 4
    s
    a
    • 3
    • 3
  • b

    Bernd Prünster

    07/10/2025, 10:53 PM
    FYI, here's a working* KMP MWE using Kotest 6.0.0.M5. *almost: proper test reports are only working on the JVM, but the tests are actually running on native and on the jvm (no JS thouhg, as it seems)
    s
    • 2
    • 1