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

    Olek Brzozowski

    08/29/2022, 7:54 AM
    When we use classic junit style based tests, we can use intellij shortcut -
    ctrl + arrow up / down
    to go to previous / next test. Is there the same option for kotest? I use free spec 😉
    s
    • 2
    • 4
  • g

    Gavin Ray

    08/31/2022, 6:24 PM
    Just another day wishing that Quarkus worked with Kotest 😛epecry: (I actually don't understand why it doesn't, since Quarkus apparently uses JUnit lifecycle/extension methods and Kotest is compatible with them)
    e
    s
    • 3
    • 11
  • v

    Victor Cardona

    09/08/2022, 3:36 AM
    Hi everyone! When running JUnit tests in IntelliJ you can click on a test case in the run window and the editor jumps to that test case. Are there any plans to support this with the Kotest Plug-in?
    l
    • 2
    • 2
  • a

    Adam S

    09/10/2022, 7:34 AM
    hi, is there a way of disabling Kotest for non-JVM tests when I run a Gradle build? I've updated Kotest and I'm bumping into "Nested tests are not supported" #3141. I've got a lot of nested tests so I don't want to refactor everything, or disable the tests for all platforms (it's a hobby project so only running JVM tests is fine).
    s
    • 2
    • 2
  • n

    Nathan Bedell

    09/10/2022, 3:06 PM
    Hey all. I'm curious if anyone anyone has worked on a KSP plugin for automatically generating arbitraries for simple classes (e.x. sealed + data classes). If not, time permitting, I'm definitely considering making one. But don't want to reinvent the wheel.
    e
    • 2
    • 3
  • v

    Victor Cardona

    09/13/2022, 4:20 AM
    Hi everyone! I'm running Kotest 5.4.2, and I'm trying to disable some tests by using
    enableOrReasonIf
    . I am following the examples in the documentation so I have the following:
    val disabledForReasonX: (TestCase) -> Enabled = { Enabled.disabled("...") }
    
    test("...").config(enabledOrReasonIf = disabledForReasonX) { ... }
    It seems like
    enabledOrReasonIf
    is only available using StringSpec. How can we do something similar in FunSpec?
    s
    • 2
    • 6
  • o

    Olai Solheim

    09/14/2022, 1:21 PM
    Hi! Is there a more elegant way to assert that an object is both non-null and assert its contents than this?
    d
    s
    +2
    • 5
    • 10
  • r

    Roach

    09/15/2022, 9:23 AM
    Hello!! i make intellij plugin which supports to create boilerplate code for unit test. So far, it supports only 3 spec (behaviour, funspec, freespec) You can download it in intellij store https://plugins.jetbrains.com/plugin/19868-kotest-boilerplate/versions Detail descriptions are in this repsitory If you like that, then click star in this repository https://github.com/tmdgusya/kotlin-test-boilerplate
  • i

    Ioannis Mavroukakis

    09/19/2022, 4:47 PM
    Hello folks! I have just started tinkering with
    kotest
    and I am happy with it thus far, except for one little thing that I cannot wrap my head around.
    class DummySpec : FreeSpec(
        {
            val mockedBeeper = mockk<Beeper>()
    
            beforeTest {
                clearAllMocks()
                println("mock cleared")
            }
    
            "beeper will beep" - {
                "when the stars have aligned" - {
                    every { mockedBeeper.beep(any()) } returns "mocked beep"
                    "and the moon is high" {
                        mockedBeeper.beep(true) shouldBe "mocked beep"
                    }
                }
            }
        },
    )
    
    class Beeper {
        fun beep(shouldBeep: Boolean): String = if (shouldBeep) {
            "BEEP"
        } else "shhhhh"
    }
    this will clear the
    mock
    three times, once for each line in the test spec. Is there anyway to use
    beforeTest
    but limit it to be executed only for the top test method? Thanks!
    l
    t
    • 3
    • 29
  • x

    xenomachina

    09/19/2022, 9:45 PM
    The output of nested data tests does not seem to match the documentation...
    s
    e
    • 3
    • 7
  • m

    Minjae Lee

    09/20/2022, 7:48 AM
    Hi, I’m kotest newbie. I just run ViewModel test but I’ve been stuck in some error. Here is the error
    io.kotest.engine.extensions.ExtensionException$BeforeEachException: java.lang.NoSuchMethodError: 'androidx.lifecycle.LiveData androidx.lifecycle.Transformations.distinctUntilChanged(androidx.lifecycle.LiveData)'
    io.kotest.engine.extensions.MultipleExceptions: io.kotest.engine.extensions.ExtensionException$BeforeEachException: java.lang.NoSuchMethodError: 'androidx.lifecycle.LiveData androidx.lifecycle.Transformations.distinctUntilChanged(androidx.lifecycle.LiveData)'
    This error might be related to Android issues, but I have no idea. Is there any ways to test for Transformations(livedata) with Kotest?
    s
    • 2
    • 10
  • k

    Klitos Kyriacou

    09/21/2022, 5:09 PM
    Hi, is there a way to say "listA should contain only the elements a, b, c"? For example:
    listOf(1, 1, 1).shouldContainOnly(1) -- passes (if there was such a function as shouldContainOnly)
    listOf(1, 1, 2, 2).shouldContainOnly(1, 2) -- passes
    listOf(1, 1, 2).shouldContainOnly(1) -- fails
    e
    d
    • 3
    • 11
  • s

    snowe

    09/23/2022, 8:01 PM
    is it possible to make tests generated like so:
    listOf(
                row(ProductType.Cash, "DFS", listOf(ServicePackage.Base, ServicePackage.BasePlus, ServicePackage.ProtectionPlus), "non-monthly-markets.csv"),
                ...
            ).forEach { (productType, market, onlyPackages, filename) ->
                "$market - $productType" - {
                    test here
                }
            }
    run in parallel? I’ve got
    object KotestProjectConfig : AbstractProjectConfig() {
        override val parallelism = 3
        override val concurrentSpecs: Int = 1
        override val concurrentTests: Int = 20
    }
    but it doesn’t seem to be doing anything.
    s
    • 2
    • 3
  • j

    João Gabriel Zó

    09/26/2022, 4:58 PM
    I’m trying to setup testcontainers with Kafka and Schema Registry but receiving this. Anybody ever gone through that?
    /bin/bash: connect: Cannot assign requested address
    /bin/bash: /dev/tcp/localhost/8081: Cannot assign requested address
    Ncat: Version 7.70 ( <https://nmap.org/ncat> )
    Ncat: Connection to 127.0.0.1 failed: Connection refused.
  • n

    Nikunj Yadav

    09/26/2022, 7:56 PM
    Looking to see if this PR is still relevant. https://github.com/kotest/kotest/pull/3200 Do you think it makes sense to merge it. If not I can close it no problem
    s
    • 2
    • 2
  • m

    MarkRS

    09/28/2022, 10:53 AM
    Are tests flavour specific (newbie question, sorry). I'm just starting to add tests to a codebase. My first couple of tests in the commonMain section of a KMM project cause a process to run without ever returning and show error messages in the run panel as
    Test events were not received
    > Task :<shared module>:compile<flavour>UnitTestJavaWithJavac NO-SOURCE
    > Task :<shared module>:test<flavour>UnitTest FAILED
    I don't want it flavour specific. I'm not aware of doing anything that would cause that, except have flavours in the project. I'm using a shouldSpec (irrelevant?) and version 5.4.2. Does that make it obvious (to you) what I've got wrong?
    s
    • 2
    • 2
  • i

    Iliyan Germanov

    09/28/2022, 4:15 PM
    Do you know when the Kotest plugin will support Android Studio Electric Eel? EDIT: I received the update for the Kotest plugin and everything works as expected :nice:
    s
    • 2
    • 3
  • t

    Toddobryan

    09/29/2022, 4:59 AM
    I'm getting a weird/annoying error.
    Arb.bind(Arb.string(), Arb.string()).checkAll { sp1, sp2 ->
    None of the following functions can be called with the arguments supplied: public fun <A, B> Arb.Companion.bind(arbs: List<Arb<TypeVariable(A)>>, fn: (List<TypeVariable(A)>) -> TypeVariable(B)): Arb<TypeVariable(B)> defined in io.kotest.property.arbitrary public fun <T : Any> Arb.Companion.bind(providedArbs: Map<KClass<*>, Arb<*>>, kclass: KClass<TypeVariable(T)>): Arb<TypeVariable(T)> defined in io.kotest.property.arbitrary
  • t

    Toddobryan

    09/29/2022, 5:00 AM
    In other words, it's not seeing the overloads of
    bind
    that take several generators in a varargs-ish way. Do I need to not import something that I am importing or import something that I'm not?
  • t

    Toddobryan

    09/29/2022, 5:17 AM
    Nvm. I figured it out by looking more closely at the types. For posterity, you need to combine the values to create a new
    Generator
    , i.e.
    Arb.bind(Arb.string(), Arb.string()) { s1, s2 -> Pair(s1, s2) }.checkAll { (s1, s2) -> ... }
    Sorry for the noise.
    e
    • 2
    • 1
  • o

    Olai Solheim

    09/29/2022, 12:21 PM
    Does the kotest-bom:5.4.2 work with kotest-assertions-core-jvm for webapp development on the JVM? Seems it includes a bunch of things, but not the one I need:
    [ERROR]     'dependencies.dependency.version' for io.kotest:kotest-assertions-core-jvm:jar is missing. @ line 41, column 21
  • m

    MarkRS

    09/30/2022, 12:12 PM
    My (Android) product flavours have (almost) nothing to do with functionality, so running tests for each flavour is just a waste of time. Can I make tests run just once without putting them in a flavour specific directory?
    s
    • 2
    • 3
  • s

    sam

    10/03/2022, 7:57 PM
    Kotest 5.5 is out https://kotest.io/docs/next/changelog.html
    s
    j
    l
    • 4
    • 9
  • b

    Ben Woodworth

    10/09/2022, 6:29 PM
    Hey! I'm new to using kotest and I'm trying to get it setup with a project of mine. Seems to work great running from gradle, but the intellij plugin and trying to run from the gutter icons has been painful to try and get working. I posted an issue yesterday, but no replies yet so I thought I'd post here too to get more eyes on it :)
    s
    e
    • 3
    • 6
  • s

    sam

    10/10/2022, 1:54 AM
    StringSpec surprises me a bit. FunSpec is the "default" in many examples, so that's understandable, and DescribeSpec is the Javascript style, so makes sense.
    d
    l
    i
    • 4
    • 11
  • a

    abendt

    10/11/2022, 2:24 PM
    hey folks, i am using the kotest-bom in one of my projects. It seems there is no 5.5.1 version of this artifact available although v5.5.1 of kotest was recently released. Other kotest related dependencies seem to be available example Was it an intentional change to not release the bom anymore?
    e
    • 2
    • 3
  • j

    James Eschner

    10/11/2022, 2:59 PM
    enum class Bar {
      BAR1, BAR2;
    }
    
    data class Foo {
      val enumSet: Set<Bar>,
    }
    
    val fooArb: Arb<Foo> = Arb.bind<Foo>()
    the target size requirement of 43 could not be satisfied after 430 consecutive samples
    java.lang.IllegalStateException: the target size requirement of 43 could not be satisfied after 430 consecutive sample
    My guess is that this is happening because it is trying to create a set of size 43, which is clearly impossible here. I would think that the arb generation would be smart enough to know that the maximum set size here is the number of enumerations in
    Bar
    . Thoughts? * Not a contribution *
  • a

    alex.krupa

    10/13/2022, 9:21 AM
    I can't get default configuration via
    AbstractProjectConfig
    to work. According to the docs, Kotest should automatically find these classes on the classpath and apply their configs to specs. Are there any undocumented requirements for this to work? For example, should this test case pass?
    object KotestConfig : AbstractProjectConfig() {
        override val isolationMode = IsolationMode.InstancePerLeaf
    }
    
    class KotestConfigSpec : StringSpec({
        "uses leaf isolation mode" {
            assertEquals(IsolationMode.InstancePerLeaf, isolationMode())
        }
    })
    c
    s
    • 3
    • 6
  • b

    Ben Woodworth

    10/15/2022, 12:21 AM
    Looks like failing nodejs tests don't get reported nicely in intellij since Kotlin 1.7.0. Details in the thread, and I can report a bug I just don't know which repo (I'd guess the gradle plugin, but could see it being the IDEA plugin)
    s
    • 2
    • 7
  • r

    RileyMichael

    10/17/2022, 8:47 PM
    Hello! I'm having a bit of an issue registering dynamic tests after upgrading to kotest 5.x.x. I'm abusing delegates for a nicer testing DSL which worked fine previously (although gross), however now
    registerTest
    just blocks endlessly. I've thrown together a simple working example and a reproduction. Has there been any significant changes to test registration between 4.x.x and 5.x.x?
    s
    • 2
    • 2
Powered by Linen
Title
r

RileyMichael

10/17/2022, 8:47 PM
Hello! I'm having a bit of an issue registering dynamic tests after upgrading to kotest 5.x.x. I'm abusing delegates for a nicer testing DSL which worked fine previously (although gross), however now
registerTest
just blocks endlessly. I've thrown together a simple working example and a reproduction. Has there been any significant changes to test registration between 4.x.x and 5.x.x?
s

sam

10/17/2022, 10:29 PM
Yep that stuff was changed a lot. You might have some coroutine / thread locks. Can you share code.
r

RileyMichael

10/18/2022, 8:51 PM
That's what I was thinking since we don't have suspending properties / I'm using
runBlocking
within the delegate (which just happened to work prior). The above links should be complete examples, is there anything particular you were wanting me to share?
View count: 3