https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
kotest
  • o

    Oliver.O

    08/29/2021, 8:53 PM
    Is a
    suspend
    version of
    shouldThrow
    missing for a reason or should I file an issue?
    s
    l
    j
    • 4
    • 17
  • g

    Gavin Ray

    08/30/2021, 4:44 PM
    @sam I've raised an issue on Quarkus repo about getting Kotest properly integrated. I also filed a PR to update the Quarkus example to latest deps, just as housekeeping 👍 One of the Quarkus devs who is more familiar with/has worked on the JUnit integration commented on the repo after pulling the broken example. Whenever you're not in 🌴 mode, do you think you'd be able to join in on the conversation here? Would be appreciated -- I'm not an expert in either Kotest, JUnit, or Quarkus unfortunately 😅 https://github.com/quarkusio/quarkus/issues/19749
    👀 1
    s
    s
    • 3
    • 28
  • j

    Javier

    09/02/2021, 6:28 PM
    Until 5.0 there not will be the new targets no? Is there a date for it?
    s
    • 2
    • 5
  • s

    sam

    09/02/2021, 7:13 PM
    If so, it's coming in 5.0 - currently you can use it in snapshot mode
    🎉 1
    🙏 1
    b
    • 2
    • 18
  • e

    Emil Kantis

    09/02/2021, 7:32 PM
    This currently fails, since Kotest is not comparing literals. Would it make sense to raise an issue on this?
    test("comparing doubles") {
             "3.123456789123457" shouldNotEqualJson "3.123456789123456789123456789"
          }
    s
    • 2
    • 4
  • s

    sam

    09/10/2021, 12:23 PM
    If anyone wants to try MPP support https://kotest.io/docs/framework/multiplatform.html
    s
    p
    • 3
    • 17
  • m

    mitch

    09/11/2021, 1:51 PM
    @sam i’ve got a proposition for you. It’s about introducting continuation-passing style to the current arbitrary builder to improve its ergonomics and simplify how we might build, compose, and generate arbs. I’ve got a PR up for you to hopefully illustrate the proposed solution as well as the problem that solves. Hope you can take a bit of a peek when you’ve got the time https://github.com/kotest/kotest/issues/2493
    👍 2
    s
    g
    • 3
    • 78
  • t

    tim

    09/14/2021, 12:33 PM
    Hello not sure if i should ask in here or in the testcontainers slack so apologies if this is in the wrong place. i'm using tests containers + kotest for integration tests (mongo + kafka containers). I'm finding that the first integration test passes, but subsequent tests are failing because the host machine ports are now unavailable. Everything works in isolation, its only when all my integration tests are run that the issue pops up. I've tried putting in a short delay after the containers are told to stop but it doesn't seem to work. Any suggestions?
    l
    s
    • 3
    • 15
  • j

    Joel Hess

    09/14/2021, 7:37 PM
    Hello, Is there support for returning a value from the new eventually API’s? I’m looking at https://kotest.io/docs/framework/concurrency/eventually.html for details. I currently have something like this with kotest in 4.4:
    suspend fun RecommendationsExhaustedEventRepository.findByCausationIdEventually(causationId: UUID): RecommendationsExhaustedEvent {
        return eventually(30.seconds, IllegalStateException::class) {
            checkNotNull(
                this.findByCausationId(causationId)
            )
        }
    }
    and trying to do the same thing with 4.6. FWIW, I’m also fine with leaving the eventually as is, and not moving to the new API, but I get this too:
    java.lang.NoSuchMethodError: 'java.lang.Object io.kotest.assertions.timing.EventuallyKt.eventually-8-LJAvk(double, kotlin.reflect.KClass, kotlin.jvm.functions.Function1, kotlin.coroutines.Continuation)'
    I see that error with Kotlin 1.4.32 and 1.5.30
    s
    j
    • 3
    • 5
  • d

    dimsuz

    09/15/2021, 2:41 PM
    I've just added a
    config=
    to
    checkAll
    with two gen-arguments and it started to throw StackOverflowException. I checked in sources and it looks like it does indeed recursively calling itself: source on github Shouldn't it call
    proptest
    instead?
    s
    • 2
    • 6
  • j

    James Eschner

    09/16/2021, 9:06 PM
    Trying to debug a test inside of a
    ShouldSpec
    should
    block. Test looks something like this:
    class MyTest : ShouldSpec({
      val foo = "bar"
    
      should("do something") {
         true shouldBe true // place breakpoint here
      }
    })
    If I run the test using the Kotest plugin in debug mode and place a breakpoint at the
    true shouldBe true
    line I don’t see the
    foo
    variable captured in the “Variables” window like I would expect. I recall being able to debug this relatively recently so I think this is a new issue. Kotlin version — 1.5.30 IntelliJ version — IntelliJ IDEA 2021.2.2 (Ultimate Edition) Build #IU-212.5284.40 Kotest version — 4.6.1 Kotest plugin version — 1.1.36-IC-2021.1 * Not a contribution *
    o
    s
    • 3
    • 4
  • j

    Javier

    09/17/2021, 2:59 PM
    where can I find the kotest 4.6.3 changelog?
    s
    • 2
    • 6
  • j

    Justin Tullgren

    09/17/2021, 4:46 PM
    Any way to get more information out of kotest? I have a test run that gets through 3 tests successfully and then just hangs (using gradle or kotest plugin).
    s
    • 2
    • 48
  • j

    Jgafner

    09/19/2021, 11:25 AM
    Hi Is there a way to assert a function is invoke a X number of times ? (X can be zero ) - could not find it in the kotest docs ( also I don’t see a search text field in the docs..) Thanks
    s
    • 2
    • 6
  • j

    Justin Tullgren

    09/23/2021, 11:13 PM
    Anyone know where the https://kotest.io/docs/extensions/junit_xml.html reporter is? I can't find the gradle coordinate
    s
    p
    • 3
    • 9
  • s

    Sangram Bankar

    09/24/2021, 5:02 PM
    Hello All, @sam has anyone came across the issue after upgrade of gradle version to 7.2 to add support for android jetpack compose. The test cases do pass but the build fails with an exception
    Received a completed event for test with unknown id '8.4'. Registered test ids: '[8.1, :app:testDebugUnitTest, 8.2]'
    Here are my gradle settings
    ------------------------------------------------------------
    Gradle 7.2
    ------------------------------------------------------------
    
    Build time:   2021-08-17 09:59:03 UTC
    Revision:     a773786b58bb28710e3dc96c4d1a7063628952ad
    
    Kotlin:       1.5.21
    Groovy:       3.0.8
    Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
    JVM:          11.0.8 (JetBrains s.r.o 11.0.8+10-b944.6916264)
    OS:           Mac OS X 10.16 x86_64
    Guys any help would be appreciated or i have to rewrite all my existing unit tests in the project using junit5 or junit4. I have also added a detailed explanation https://github.com/kotest/kotest/issues/2331#issuecomment-923422181
    s
    • 2
    • 16
  • p

    Philipp Mayer

    09/29/2021, 8:51 AM
    Hello everyone! I have the following data structure:
    data class User(
        val id: String,
        val someTime: LocalDateTime,
        val someDetails: SomeDetails,
    ) {
        data class SomeDetails(
            val otherId: String,
            val otherTime: LocalDateTime,
        )
    }
    
    val user = User(
        id = "1",
        someTime = LocalDateTime.now(),
        someDetails = User.SomeDetails(
            otherId = "a",
            otherTime = LocalDateTime.now().plusSeconds(1)
        )
    )
    val otherUser = User(
        id = "1",
        someTime = LocalDateTime.now().plusHours(1),
        someDetails = User.SomeDetails(
            otherId = "a",
            otherTime = LocalDateTime.now().plusSeconds(22)
        )
    )
    I would like to write a test that ignores both
    LocalDateTime
    fields. Something in the lines of:
    class SomeTest {
        @Test
        fun `should ignore localdatetime fields`() {
            user.shouldBeEqualToIgnoringFields(otherUser, User::someTime, User.SomeDetails::otherTime)
        }
    }
    Is there any matcher that I might have missed when going through the docs? Thanks in advance!
    t
    l
    • 3
    • 7
  • v

    Vector Sigma 800

    10/02/2021, 1:25 PM
    Hello all!! is it possible to configure kotest to use TestCoroutineScope instead of normal coroutines? https://stackoverflow.com/questions/69417255/kotest-and-kotlinx-coroutines-test-integration
    s
    • 2
    • 2
  • a

    Ashish Kumar Joy

    10/08/2021, 1:27 AM
    I am currently using Eventually but still with that, there are times when test fails, the Code under test schedule some task on a separate thread pool, which is supposed to completed with 2-3 seconds yet depending upon the load on CI agent where these test are running they can take say 7-8 second to complete resulting in test failure, one option is to increase timeout duration in eventually above 8 second, but depending upon the number of such test this will increase the overall build time.
    j
    s
    t
    • 4
    • 9
  • a

    atara

    10/08/2021, 2:51 AM
    Hi developers. I have a test with 2 `Arb`s and would like to filter the second based on the first value. The best I could think of was this
    Arb.pair(ArbA, ArbB).filter {it.first != it.second}
    But then the result is a pair that I need to unpack for the test. Is there a better way?
    m
    • 2
    • 2
  • p

    phil-t

    10/08/2021, 3:18 PM
    Hi, after updating my Kotlin and Kotest versions in IntelliJ I’m getting the below warning where I’m using
    .config
    to tag my tests, for example:
    "my test".config(tags = setOf(TestTag)) {
        // Test stuff here
    }
    warning on .config -
    This declaration is experimental due to signature types and its usage must be marked (will become an error in 1.6) with '@kotlin.time.ExperimentalTime' or '@OptIn(kotlin.time.ExperimentalTime::class)'
    TestTag would be defined like this -
    object TestTag : Tag()
    Is there something else I should be doing to tag my tests instead of using
    .config
    ?
    s
    • 2
    • 6
  • m

    mitch

    10/11/2021, 8:58 PM
    Is there any M1 or M2 release planned for https://github.com/kotest/kotest-extensions-arrow ? is that namespace correct? should that be under
    kotest.extensions.arrow.*
    ?
    s
    • 2
    • 1
  • e

    elect

    10/12/2021, 5:21 AM
    I'm bumping up some lib with the latest(sh) kotest
    api("io.kotest:kotest-runner-junit5:4.6.1")
    api("io.kotest:kotest-assertions-core:4.6.1")
    this used to work in the past, but now it doesnt get picked up any more
    init {
            val BCN_Epileptic = "BCN_Epileptic.X"
            BCN_Epileptic {
                ...
            }
        }
    It works only if I use instantiate and
    invoke
    on the string itself directly, that is
    init {
            "BCN_Epileptic.X" {
                ...
            }
        }
    s
    • 2
    • 1
  • j

    Javier

    10/17/2021, 3:56 AM
    Is it possible to pass two dir files and assert all files and directories have the same structure and content?
    j
    s
    l
    • 4
    • 137
  • s

    Sangmin Lee

    10/17/2021, 11:13 AM
    According to this documentation, An innermost test in FreeSpec must not use ‘-’(minus sign). But the innermost test with the minus sign works well 🤔 What’s supposed to be wrong with it??
    s
    l
    • 3
    • 8
  • c

    charleskorn

    10/18/2021, 4:44 AM
    Is Gradle test filtering supported with Kotlin/Native? I’ve tried
    ./gradlew macosX64Test --tests '*MyTestClass'
    and
    ./gradlew macosX64Test --tests 'MyTestClass'
    but in both cases all tests still ran
    s
    j
    • 3
    • 5
  • m

    Michael Strasser

    10/20/2021, 11:46 AM
    Is it possible to compare function types? Given something like:
    typealias Matcher = (String) -> Boolean
    data class Thing(matcher: Matcher)
    This fails:
    it("compares values of function types") {
        val testThing = Thing({ it.startsWith("test") })
        testThing.matcher shouldBe { it.startsWith("test") }
    }
    with messages like:
    expected:<(kotlin.String) -> kotlin.Boolean> but was:<(kotlin.String) -> kotlin.Boolean>
    s
    • 2
    • 2
  • l

    Lidonis Calhau

    10/20/2021, 12:49 PM
    Is there a way to group assertSoftly into one matcher that can be reused ?
    assertSoftly(foo) {
        shouldNotEndWith("b")
        length shouldBe 3
    }
    ->
    foo shouldBe customAssert
    s
    • 2
    • 6
  • m

    Mervyn McCreight

    10/20/2021, 5:49 PM
    Hi folks 🙂 I stumbled upon an issue with the
    JUnitXmlReporter
    in one of my projects. I set it up according to the documentation, but the final XML files still only contain the leaf name of the tests for nested tests. What I have seen while debugging that the reporter itself is working correctly and directly after doing the file operations in the reporter the XML files are correct. But something happens afterwards overwriting the XML files from the
    JUnitXmlReporter
    😞 Anyone got an idea or can see the same behaviour? Im using version
    4.6.3
    of KoTest.
    s
    • 2
    • 18
  • e

    Emil Kantis

    10/21/2021, 8:05 AM
    Is there any more convenient pattern for invoking two blocking things that depend on each other than doing the following?
    test("client-server test") {
      listOf(
        async { client.sendRequest() }
        async { 
          val req = server.takeRequest()
          req.path shouldBe "/api/v1/hello"
        }
      ).joinAll()
    }
    r
    • 2
    • 2
Powered by Linen
Title
e

Emil Kantis

10/21/2021, 8:05 AM
Is there any more convenient pattern for invoking two blocking things that depend on each other than doing the following?
test("client-server test") {
  listOf(
    async { client.sendRequest() }
    async { 
      val req = server.takeRequest()
      req.path shouldBe "/api/v1/hello"
    }
  ).joinAll()
}
r

Richard Gomez

10/21/2021, 9:43 AM
I would personally do something like below.
coroutineScope
will wait for all child coroutines to complete before exiting;`async` is meant to be used with
.await()
, so if you don't care about the return value you can just use
launch
.
test("client-server test") {
  coroutineScope {
    launch { client.sendRequest() }
    launch { 
      val req = server.takeRequest()
      req.path shouldBe "/api/v1/hello"
    }
  }
}
Coroutines aren't necessarily the best fit if both
sendRequest()
and
takeRequest()
are blocking, but it may not matter for a test.
e

Emil Kantis

10/21/2021, 1:20 PM
will try that, thx 🙂
View count: 2