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
  • l

    Luke

    01/14/2022, 9:54 PM
    In the assertion library, we have access to both:
    infix fun <A : CharSequence> A?.shouldMatch(regex: String): A
    infix fun <A : CharSequence> A?.shouldMatch(regex: Regex): A
    Is there a reason for having only the negation for the String parameter?
    l
    • 2
    • 5
  • t

    Tadeas Kriz

    01/16/2022, 11:06 AM
    Hey there, I don't mean to rush, I just wanted to ask about a plan for the 5.1 release with support for Coroutines 1.6. I wanted to use the latest SNAPSHOT, but it doesn't seem to have
    iossimulatorarm64
    binaries
    l
    s
    • 3
    • 8
  • s

    sam

    01/16/2022, 9:43 PM
    Kotest 5.1.0 has been released. https://kotest.io/docs/changelog.html
    :kotest: 2
    ✅ 3
    :kotlin-intensifies: 4
    s
    • 2
    • 3
  • m

    Michael Vandendriessche

    01/19/2022, 2:09 PM
    Hi everyone, I've just started working on an app (which has many architecture and code quality problems) without any tests and after comparing test frameworks I think Kotest would be my favourite. I've been having some difficulties with setting it up though, mostly in the dependencies department. I wanted to know if the [getting started guide](https://kotest.io/docs/quickstart/) is still up to date and complete. Do I not need any other dependencies than these listed below for unit testing with kotest, with the kotest assertions?
    testImplementation 'io.kotest:kotest-runner-junit5-jvm:5.1.0'
    testImplementation 'io.kotest:kotest-assertions-core-jvm:5.1.0'
    Currently my test dependencies look like this (yes with all the comments... don't worry, I didn't commit it yet)
    //    testImplementation 'junit:junit:4.12'
        testImplementation 'io.kotest:kotest-runner-junit5-jvm:5.1.0'
        testImplementation 'io.kotest:kotest-assertions-core-jvm:5.1.0'
    //    testImplementation 'io.kotest:kotest-assertions-json-jvm:5.1.0'
        testImplementation 'io.kotest.extensions:kotest-extensions-robolectric:0.5.0'
        implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" // M: Why do I need this? ask in the kotlin kotest channel
    //    testImplementation 'org.json:json:20180813' // M: needed for using JSONObject in unit tests, which is part of the android framework
    //    testImplementation 'com.googlecode.json-simple:json-simple:1.1.1' // M: needed for using JSONObject in unit tests, which is part of the android framework
    //    testImplementation 'org.robolectric:robolectric:4.6' // M: use kotest robolectric instead
    
    //    testImplementation "de.mannodermaus.gradle.plugins:android-junit5:1.8.2.0"
        // (Required) Writing and executing Unit Tests on the JUnit Platform
    //    testImplementation "org.junit.jupiter:junit-jupiter-api:5.8.2"
    //    testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.8.2"
    
        // (Optional) If you need "Parameterized Tests"
    //    testImplementation "org.junit.jupiter:junit-jupiter-params:5.8.2"
    
    //    androidTestImplementation 'com.android.support.test:rules:1.0.2'
    //    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    //    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    I'm using robolectric here because I wanted to test something with json but apparently that's part of the android platform and couldn't get it to work by including json dependencies separately. I had to include the kotlin-reflect library, however I'm not doing any reflection. Why do I need this dependency? Where is it using reflection? At this moment I'm having following error about androidx.
    This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.
    The following AndroidX dependencies are detected: androidx.test:monitor:1.4.0, androidx.annotation:annotation:1.1.0
    Where is androidx used? Why do I need to add this? I do not see any references to androidx in our codebase. I suppose I will add it but I want to understand it. I was wondering if I also should include the mannodermaus plugin for junit5 and the junit dependencies or those are covered by kotest already or are those not relevant for kotest? Most of my android knowledge dates from around 2015. If someone can shed more light on the things above, that would be great! I'm happy to be working on Android again! 😄
    e
    • 2
    • 9
  • r

    Rajkumar Singh

    01/20/2022, 12:15 AM
    I upgraded the Kotest version from <kotest.version>4.6.4</kotest.version> to <kotest.version>5.1.0</kotest.version> in my maven pom. and now I'm getting the following error. this is a spring boot project with 100% Kotlin.
    t
    • 2
    • 14
  • d

    dave08

    01/23/2022, 2:17 PM
    @LeoColman Did something change in the Robolectric extension? I started getting
    No instrumentation registered! Must run under a registering instrumentation.
    ... I'm using kotest 4.6.4 and tried the 0.5.0 and 0.4.0 extensions...
    l
    m
    • 3
    • 13
  • d

    dave08

    01/25/2022, 11:53 AM
    Is there a way to run regular JUnit tests in the same test module as Kotest 4.6.x tests? (see thread for exception I'm getting...)
    w
    s
    • 3
    • 5
  • k

    Karlo Lozovina

    01/25/2022, 11:32 PM
    Is there any way that in the same test I have these two assertions, first one passes second one fails? Don't get it...
    o1 shouldBe o2
    (o1 == o2) shouldBe true
    s
    • 2
    • 19
  • m

    Mervyn McCreight

    01/26/2022, 6:54 PM
    Hey - When updating to
    5.1.0
    I noticed that the documentation points out a deprecated way to add the junit_xml reporter to the ProjectConfig. I opened a PR here: https://github.com/kotest/kotest/pull/2801
    s
    • 2
    • 1
  • m

    Mervyn McCreight

    01/28/2022, 1:44 PM
    Hmm - after updating to KoTest 5.1.0 I have a problem that tests do not start to run when I set
    parallism
    to something else than 1. It worked before - is anyone having the same problem, or is this something specific to the project I am working in? 🤔
    s
    • 2
    • 6
  • l

    LeoColman

    01/29/2022, 11:55 AM
    Hey guys! Any particular reason for the extensions page to not be listed alphabetically? I think it would be easier to find what we want
    s
    • 2
    • 1
  • j

    jmfayard

    01/31/2022, 10:27 AM
    Hello, I don't understand the versioning of the many kotest modules For example https://repo.maven.apache.org/maven2/io/kotest/kotest-assertions-ktor/ is at 4.4.3 https://repo.maven.apache.org/maven2/io/kotest/kotest-core/ is at 4.1.3 https://repo.maven.apache.org/maven2/io/kotest/kotest-assertions-json/ is at 5.1.0
    l
    s
    • 3
    • 6
  • c

    christophsturm

    02/01/2022, 11:57 AM
    I have a test suite that uses multiple junit engines, and when i run tests by uniqueId kotest also runs tests even when the uniqueId clearly states a different engine than kotest.
    [engine:failgood]/[class:...]/[class:...]
    I think kotest should just run no tests when the uniqueid selector is used with a different engine.
    👍🏻 1
    🎉 1
    s
    • 2
    • 12
  • j

    Joel Hess

    02/01/2022, 9:37 PM
    Just updated from v5.0.3 to 5.1.0 and now I’m getting
    java.lang.NoClassDefFoundError: kotlinx/coroutines/test/TestDispatcher
    all over the place when i run my test set. Using Kotlin 1.6.10. I don’t have anything that is explicitly drawing in that coroutine package.
    s
    • 2
    • 4
  • d

    dimsuz

    02/03/2022, 11:16 AM
    Hello! Trying to write data-driven-tests as described in the manual, but none of the below finds
    withData
    , unresolved reference. Was there an api change? This is
    5.1.0
    class JobFlowCombinatorsTest : ShouldSpec({
      context("state merging") {
        withData() {}
      }
      should("correctly combine states") {
        withData() {}
      }
    })
    s
    • 2
    • 7
  • t

    tim

    02/08/2022, 1:02 PM
    Is there a way in the kotest intellij plugin to set junit’s setForkEvery? I’d like to force a new jvm for each spec if i can. I can do it when running from the cli, but it doesn’t appear that the kotest extension respects the build.gradle.kts config?
    s
    • 2
    • 2
  • p

    Pitel

    02/08/2022, 1:33 PM
    I'm trying to use kotest with coroutines and robolectric, so I have this simple test:
    @RobolectricTest
    class RoboTest : StringSpec( {
        "test" {
            println(1111111)
            delay(500)
            println(22222)
            1 + 1 shouldBe 2
            println(3333)
        }
    })
    But it never finishes! It prints 11111 and then just hangs. Any idea why?
    s
    n
    • 3
    • 5
  • n

    nelson ramirez

    02/08/2022, 5:27 PM
    Hi, I'm trying to get the robolectric kotest extension working on my android project but I'm running into this error when running the test:
    java.lang.IllegalStateException: No instrumentation registered! Must run under a registering instrumentation.
    I searched around for an example project or usage and came up blank. Is there a sample project out there?
    • 1
    • 1
  • m

    Mini

    02/08/2022, 7:12 PM
    Im not sure if this is a kotest problem, or my understanding of map/combine is lacking, but Im struggling to understand why combine does not work as expected in my tests… Basic example in 🧵
    s
    • 2
    • 5
  • k

    kierans777

    02/08/2022, 11:30 PM
    Hi all. I'm new to Kotest, but I am loving it. I'm writing a library that needs to be cross platform so using MPP, and Kotest for my all my tests. I can't seem to run my tests in iOS because of a linking error, and was hoping to get some help.
    > Task :my-library:linkDebugTestIosX64 FAILED
    e: Could not find "io.kotest:kotest-assertions-api" in [ ... ]
    FAILURE: Build failed with an exception.
    // kotestVersion = "5.1.0"
    commonTest {
        dependencies {
            implementation "io.kotest:kotest-framework-engine:${rootProject.ext.kotestVersion}"
            implementation "io.kotest:kotest-assertions-core:${rootProject.ext.kotestVersion}"
            implementation "io.kotest:kotest-property:${rootProject.ext.kotestVersion}"
            implementation "io.kotest.extensions:kotest-assertions-arrow:1.2.2"
    
            runtimeOnly "io.kotest:kotest-assertions-api:${rootProject.ext.kotestVersion}"
        }
    }
    s
    i
    • 3
    • 40
  • d

    dimsuz

    02/09/2022, 12:24 PM
    Tried to write a test with
    testCoroutineScheduler
    in
    commonMain
    in a KMP project and it seems that it is defined only form jvm projects. Is there some reason to restrict to jvm-only?
    s
    l
    k
    • 4
    • 5
  • n

    nelson ramirez

    02/09/2022, 4:32 PM
    Hi, is the Robolectric kotest extension abandoned?
    s
    l
    w
    • 4
    • 15
  • p

    Philipp Mayer

    02/11/2022, 10:25 AM
    Hi there, I’m currently starting to integrate the Kotest runner in our test suite as we are really happy with the already used assertions library. It seems like Kotest 5.1.0 is not working with Spring 2.6.3 Webflux, since Webflux seems to drag in
    org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.2
    (even though we specified the dep as 1.6.0) and Kotest required
    1.6.0
    . Having both
    1.6.0
    and
    1.5.2
    of
    corouitnes-core
    on the classpath seems not to work. Did anybody else run into this problem? Right now downgrading to
    5.0.3
    is the only solution I could find. Any help is appreciated. Thanks!
    s
    • 2
    • 2
  • c

    charleskorn

    02/12/2022, 2:59 AM
    I’m trying to debug some tests that use
    shouldContain
    , but the assertion failure messages only include the first five elements. Is there a reason for this? It’d be great if the error included the full list, or if there was some way to configure this behaviour
    • 1
    • 1
  • b

    Benni

    02/13/2022, 6:22 PM
    Hey folks, (I am new to the channel and I hope this is the right place to ask). I am getting this exception when running Kotest on a gradle travis-ci build but not when I run it on my local mac book:
    UnknownClass.Kotest > UnknownClass.initializationError FAILED
        java.lang.UnsupportedClassVersionError at ClassLoader.java:-2
    (see log here). I am using Kotlin 1.6.2 and Kotest 5.10 (see versions here) I am a little unclear how to debug this and any pointers are greatly appreciated.
    r
    s
    • 3
    • 19
  • l

    LeoColman

    02/13/2022, 11:46 PM
    Hey guys! Can I get a review at https://github.com/kotest/kotest-extensions-mockserver/pull/1?
    s
    • 2
    • 2
  • p

    Pitel

    02/14/2022, 9:19 AM
    How can I use Kotest with Android Instrumentation test (
    androidTest
    )? I don't need to test UI, just Room database. It seems my tests are not even run. Or maybe it does, I don't know. But the result of
    connectedDebugAndroidTest
    is success, even when there is a test that must be definitely failing.
    w
    • 2
    • 3
  • p

    phil-t

    02/14/2022, 12:12 PM
    👋 I found a problem when doing an assertion on a nullable variable e.g.
    nullableThing?.shouldBe(something)  // This works
    nullableThing?.shouldBeGreaterThan(something). // This doesn't work
    If nullableThing is null the safe call stops the assertion from being called, so the tests passes when it shouldn’t. I found two ways to fix this but neither seem ideal to me: • Add another assertion to check that the thing isn’t null e.g.
    nullableThing shouldNotBe null
    • Use
    !!.
    instead of
    ?.
    but this gives a null pointer exception when the test fails which could lead to confusion Is there a better way to deal with assertions on nullable variables?
    c
    w
    +3
    • 6
    • 17
  • d

    Dan T

    02/15/2022, 2:50 PM
    I hit the strong encapsulation issue using the system extension
    withEnvironment
    on JDK 17.
    java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Map java.util.Collections$UnmodifiableMap.m accessible
    at
    SystemEnvironmentExtensions.kt:115
    . I can get around the issue by adding
    --add-opens java.base/java.util=ALL-UNNAMED
    , but I'm wondering if there's a different path forward for this feature that doesn't require the workaround.?
    s
    • 2
    • 1
  • m

    mitch

    02/16/2022, 10:23 AM
    @sam halp have you seen anything like this before?
    org.junit.platform.commons.JUnitException: TestEngine with ID 'kotest' failed to execute tests
    Caused by: java.lang.IllegalArgumentException: Comparison method violates its general contract!
    s
    • 2
    • 11
Powered by Linen
Title
m

mitch

02/16/2022, 10:23 AM
@sam halp have you seen anything like this before?
org.junit.platform.commons.JUnitException: TestEngine with ID 'kotest' failed to execute tests
Caused by: java.lang.IllegalArgumentException: Comparison method violates its general contract!
junit annoyingly also swallowed the stacktrace so i need to figure out how to enable it. it also doesn’t consistently happen.
s

sam

02/16/2022, 11:00 AM
Sounds like a custom comparator
m

mitch

02/16/2022, 11:15 AM
looking
i can’t find any custom comparator in that project.. also trying to check in junit or kotest.
hmm i can’t see anything wrong in kotest either. must be something in that project. i’ll try enabling stack trace and get back to you
Thanks Sam!
@sam i think i found the culprit.. i’ve raised an issue there https://github.com/kotest/kotest/issues/2839
and also raised a PR with the fix
s

sam

02/21/2022, 11:38 AM
cool. Will merge once green. I think later this week I can make a 5.1.1 release with this.
🙇‍♂️ 1
maybe a 5.0.4 too
m

mitch

02/21/2022, 11:51 AM
Thanks heaps Sam!
👍🏻 1
View count: 10