https://kotlinlang.org logo
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
  • m

    mitch

    10/12/2020, 11:52 PM
    @sam qq just to clarify my understanding, am i right to understand that spring listener will try to boot up spring before each spec class that summons the bean autowiring?
    s
    t
    • 3
    • 21
  • j

    Jim

    10/14/2020, 4:44 AM
    Do the kotest tests generally run on *nix? I'm getting a failure in
    Blonde("foo", true, 23423, Paths.get("a/b/c"))
    printing as
    Blonde(a=foo, b=true, c=23423, p=a\b\c)
    but the tests expect
    Blonde(a=foo, b=true, c=23423, p=a/b/c)
    - would I break something by changing the static string to use
    File.separator
    so these tests work on windows as well? Or am I missing something here 🤔 I'm a little wary since I'm changing the clue code which seems related. https://gist.github.com/jschneidereit/251bc1392639ff18741bcb2a844e9fea
    s
    • 2
    • 5
  • j

    Jim

    10/14/2020, 5:45 AM
    Similar deal,
    shouldBeSymbolicLink should check if file is symbolic link
    blows up in windows unless the test suite is running as admin. The easiest thing to do would be to just disable this test in windows. Possible solutions are to just disable this test in windows or check if the process is running as admin on windows using something like this: https://stackoverflow.com/a/10654463 (it works in the kotlin REPL but the SO comments make it sound like it's not a sure thing)
    s
    • 2
    • 2
  • c

    christophsturm

    10/14/2020, 2:27 PM
    does kotest support mapping like strikt?
    val subject = Pantheon.NORSE
    expectThat(subject)
      .get(Pantheon::ruler) // reference to a property
      .get { toString() }   // return type of a method call
      .isEqualTo("Odin")
    s
    m
    • 3
    • 14
  • j

    jlw

    10/15/2020, 1:21 PM
    I’m in the process of migrating some tests from Spek to Kotest, and I’m running into a problem where gradle won’t execute my kotest specs when I have include the spek test engine. Has anyone ran into this before? Right now it seems I can either execute either spek or kotest but not both.
    s
    • 2
    • 17
  • h

    huehnerlady

    10/15/2020, 2:21 PM
    Hi, I am in the middle of convincing my colleagues to use kotlin with kotest instead of groovy with spockframework for testing. One point was that spock has a nice framework with the key workd `given`/`when`/`then`/`expect`. Is there anything similar to this for kotest as well?
    :yes: 2
    ☑️ 1
    s
    • 2
    • 1
  • h

    huehnerlady

    10/16/2020, 8:44 AM
    Since the last kotest plugin update I cannot start the whole testclass anymore. Before I could do that. What do I have to do in order for that to work again? Same behaviour with freespec describeSpec and behaviourspec 🤔
    ☑️ 1
    s
    • 2
    • 4
  • r

    Rob Elliot

    10/16/2020, 5:11 PM
    I’m probably being thick, but I’m finding that I don’t get nice coroutine stacktraces in IntelliJ when my test fails in an
    eventually
    block. VM options:
    -ea -Dkotlinx.coroutines.debug=on -Dkotlinx.coroutines.stacktrace.recovery=true
    (belt, braces, stapled on to stomach).
    s
    • 2
    • 28
  • a

    alexfacciorusso

    10/18/2020, 1:57 PM
    Good news for Android devs using Kotest: work in progress on LiveData assertions and extension listener! 😄
    ❤️ 1
    🎉 1
    j
    w
    +2
    • 5
    • 40
  • w

    wasyl

    10/20/2020, 11:42 AM
    How does Kotest discover tests? Does it scan entire classpath or just the classes from the tests source set? Is it configurable somehow, if we want to only scan classes under specific package?
    s
    p
    c
    • 4
    • 72
  • w

    wasyl

    10/20/2020, 3:52 PM
    Another topic: is it a known issue that inline classes don’t work well in forall? Or maybe it’s something wrong with our setup (I don’t see what it could be though)
    s
    • 2
    • 28
  • c

    christophsturm

    10/22/2020, 8:54 AM
    i wonder what “data driven tests” add to the table. can’t i just use
    listOf(
           PythagTriple(3, 4, 5),
           PythagTriple(6, 8, 10),
           PythagTriple(8, 15, 17),
           PythagTriple(7, 24, 25)
        ).map{ (a, b, c) -> test("test %a %b %c") { ...}
    in a fun spec?
    s
    • 2
    • 5
  • h

    huehnerlady

    10/22/2020, 3:06 PM
    When I try to set isolationMode on Project level, it does not seem to count I have the following configuration
    object KotestConfig : AbstractProjectConfig() {
    
      override val isolationMode = IsolationMode.InstancePerTest
    
      override fun listeners() = listOf(SpringListener)
    }
    But when I set a break point in a test I can see that isolationMode is actually null. Also tried to use the deprecated function, same result. I can also see that the mode is not working as I have one test bleeding into the other. With the listeners it seems to work as the Spring tests are running without having the spring listener added Any idea what I am doing wrong?
    ☑️ 1
    w
    s
    • 3
    • 31
  • w

    wasyl

    10/22/2020, 8:29 PM
    I can’t seem to be able to enable logging for Kotest 😕 Any idea what I may be missing? I want to see logs in console when running tasks, I tried: • setting
    systemProp.KOTEST_DEBUG=true
    in
    gradle.properties
    •
    tasks.withType(Test) { systemProperty("KOTEST_DEBUG", true) }
    • exporting KOTEST_DEBUG env variable in console • passing -DKOTEST_DEBUG=true in ./gradlew params
    s
    • 2
    • 20
  • w

    why

    10/25/2020, 10:13 AM
    Hi, I’m using FreeSpec style in my project, I reached +1400 lines of test code in one test class, the problem is IntelliJ became super slow and unresponsive when I want to add any new test to that test class, does it have to do with style or ? any ideas?
    j
    s
    • 3
    • 3
  • s

    Sourabh Rawat

    10/25/2020, 2:40 PM
    Hi is there any multiplatform project available where I can see how to configure kotest as multiplatform. I am working on a full stack web application but cant seem to make kotest work for commonTest module
    s
    • 2
    • 2
  • j

    Jim

    10/26/2020, 6:23 PM
    Does the kotest annotation spec respect inner classes? I ended up using them in my test suite similar to
    context
    in other kotest spec styles. 🤔
    s
    • 2
    • 9
  • r

    rpillay

    10/27/2020, 6:16 AM
    Does anyone else notice extremely poor performance of IntelliJ IDEA when editing kotest files? All versions I've tried. I'm not sure what it is about the kotest files that it doesn't like...
    👍 1
    w
    l
    s
    • 4
    • 29
  • k

    kopper

    10/28/2020, 2:11 AM
    When I use tags in IntelliJ by specifying VM options:
    -Dkotest.tags="UnitTest"
    the report with test results includes test classes that were not tagged. They are listed at the end of report as single line per class, i.e. no specific tests are reported. I tagged test classes, so AFAIU the specs should not even be instantiated (and they aren't when I use tags in Maven). Is this UX bug?
    r
    s
    • 3
    • 35
  • s

    Sebastian Schuberth

    10/28/2020, 9:25 AM
    I'm looking for
    SkipTestException
    in kotest 4.3.0, but I cannot find it. Has it been removed from the code base?
    • 1
    • 2
  • c

    christophsturm

    10/29/2020, 12:28 PM
    are all kotest styles affected by the IDEA slowdown?
    s
    • 2
    • 19
  • l

    Luke

    10/30/2020, 6:02 PM
    Is there an opposite to
    collection shouldExist { … }
    ? I want to test that the collection does not contain an element matching the predicate
    s
    • 2
    • 3
  • s

    snowe

    10/30/2020, 8:57 PM
    trying to help out with the junit5/quarkus stuff but can’t even get master to build.
    ❯ ./gradlew build
    
    > Configure project :
    Kotlin Multiplatform Projects are an Alpha feature. See: <https://kotlinlang.org/docs/reference/evolution/components-stability.html>. To hide this message, add 'kotlin.mpp.stability.nowarn=true' to the Gradle properties.
    
    
    > Task :kotest-assertions:kotest-assertions-shared:compileCommonMainKotlinMetadata FAILED
    e: /Users/tyler.thrailkill/dev/code/oss/kotest/kotest-assertions/kotest-assertions-shared/src/commonMain/kotlin/io/kotest/assertions/Retry.kt: (10, 8): Unresolved reference: kotlinx
    e: /Users/tyler.thrailkill/dev/code/oss/kotest/kotest-assertions/kotest-assertions-shared/src/commonMain/kotlin/io/kotest/assertions/Retry.kt: (83, 7): Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
    public operator fun <T, R> DeepRecursiveFunction<TypeVariable(T), TypeVariable(R)>.invoke(value: TypeVariable(T)): TypeVariable(R) defined in kotlin
    e: /Users/tyler.thrailkill/dev/code/oss/kotest/kotest-assertions/kotest-assertions-shared/src/commonMain/kotlin/io/kotest/assertions/timing/Eventually.kt: (4, 8): Unresolved reference: kotlinx
    e: /Users/tyler.thrailkill/dev/code/oss/kotest/kotest-assertions/kotest-assertions-shared/src/commonMain/kotlin/io/kotest/assertions/timing/Eventually.kt: (51, 7): Unresolved reference: delay
    e: /Users/tyler.thrailkill/dev/code/oss/kotest/kotest-assertions/kotest-assertions-shared/src/commonMain/kotlin/io/kotest/assertions/timing/continually.kt: (4, 8): Unresolved reference: kotlinx
    e: /Users/tyler.thrailkill/dev/code/oss/kotest/kotest-assertions/kotest-assertions-shared/src/commonMain/kotlin/io/kotest/assertions/timing/continually.kt: (34, 7): Unresolved reference: delay
    e: /Users/tyler.thrailkill/dev/code/oss/kotest/kotest-assertions/kotest-assertions-shared/src/commonMain/kotlin/io/kotest/assertions/until/until.kt: (4, 8): Unresolved reference: kotlinx
    e: /Users/tyler.thrailkill/dev/code/oss/kotest/kotest-assertions/kotest-assertions-shared/src/commonMain/kotlin/io/kotest/assertions/until/until.kt: (82, 7): Unresolved reference: delay
    I don’t see any kotlinx dependency declared, so how is this building successfully with github actions?
    s
    • 2
    • 10
  • c

    christophsturm

    10/31/2020, 9:17 AM
    how do i configure kotest to run without junit in gradle and idea? what dependencies do I use?
    s
    • 2
    • 10
  • k

    kopper

    11/02/2020, 2:33 AM
    Is there a way to tell IntelliJ Kotest plugin to use maven-failsafe-plugin configuration for running integration tests (the same as in maven) instead of maven-surefire-plugin configuration?
    s
    • 2
    • 2
  • p

    peekandpoke

    11/02/2020, 1:55 PM
    Hi there! Has anyone observed "weird" behaviour when combining
    assertSoftly
    with
    shouldNotBe
    ? I just upgraded from the old kotlintest to kotest:4.3.1 and now some of my tests fail. When I remove the surrounding
    assertSoftly
    block then everythings is fine again. The assertions stay the same but do no longer fail! It also seems to only happen when I use
    shouldNotBe
    Any idea? Thanks!
    l
    • 2
    • 3
  • c

    christophsturm

    11/02/2020, 7:43 PM
    “You can ask Kotest to run specs in parallel to take advantage of modern cpus with several cores by setting the parallelism level (default is 1).. Tests inside a spec are always executed sequentially.” is that still true?
    s
    • 2
    • 19
  • c

    christophsturm

    11/02/2020, 11:50 PM
    i have a really strange classloader problem, here is a reduced test case:
    package r2dbcfun
    
    import io.kotest.core.spec.style.FunSpec
    import java.io.StringReader
    import kotlin.reflect.full.declaredMemberProperties
    
    class Ko2Test : FunSpec({
        listOf(1).forEach {
            context("running") {
    
                autoClose(StringReader("blah"))
                context("ctx") {
                    data class K(val name: String)
    
                    K::class.declaredMemberProperties
                }
            }
        }
    })
    s
    • 2
    • 3
  • p

    peekandpoke

    11/03/2020, 10:00 PM
    I was able to reproduce the issue described above. Please have a look at the comment on the original post. What should I do now? File a bug? If so where and how? Thanks!
    s
    • 2
    • 3
  • a

    Ahmed Mourad

    11/04/2020, 8:39 AM
    Hi, I'm trying to use Kotest with Android Instrumented tests but I'm getting this error as soon as I run my tests:
    Exception in thread "main" java.lang.ClassNotFoundException: io.kotest.engine.launcher.MainKt
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
    	at com.intellij.rt.execution.CommandLineWrapper.loadMainClassWithCustomLoader(CommandLineWrapper.java:193)
    	at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:48)
    I'm using a
    DescribeSpec
    with no
    @RunWith
    annotations:
    class SomeTests : DescribeSpec({ ... })
    This's what my
    build.gradle
    looks like:
    apply plugin: "com.android.library"
    apply plugin: "kotlin-android"
    apply plugin: "kotlin-android-extensions"
    apply plugin: "kotlin-kapt"
    apply plugin: "de.mannodermaus.android-junit5"
    ...
    
    android {
        compileSdkVersion 30
        defaultConfig {
            minSdkVersion 17
            targetSdkVersion 30
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    ...
        }
        testOptions {
            unitTests.all {
                useJUnitPlatform()
            }
        }
    }
    
    dependencies {
        implementation fileTree(dir: "libs", include: ["*.jar"])
    
        implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    
    ...
    
        androidTestImplementation "androidx.test:runner:1.3.0"
        androidTestImplementation "androidx.test:core:1.3.0"
        androidTestImplementation "androidx.test.ext:junit:1.1.2"
        androidTestImplementation 'io.kotest:kotest-runner-junit5:4.3.1'
        androidTestImplementation 'io.kotest:kotest-assertions-core:4.3.1'
        androidTestImplementation 'io.kotest:kotest-property:4.3.1'
        androidTestImplementation 'io.kotest:kotest-assertions-arrow:4.3.1'
    }
    and this's what my test configs look like:
    a
    • 2
    • 2
Powered by Linen
Title
a

Ahmed Mourad

11/04/2020, 8:39 AM
Hi, I'm trying to use Kotest with Android Instrumented tests but I'm getting this error as soon as I run my tests:
Exception in thread "main" java.lang.ClassNotFoundException: io.kotest.engine.launcher.MainKt
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
	at com.intellij.rt.execution.CommandLineWrapper.loadMainClassWithCustomLoader(CommandLineWrapper.java:193)
	at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:48)
I'm using a
DescribeSpec
with no
@RunWith
annotations:
class SomeTests : DescribeSpec({ ... })
This's what my
build.gradle
looks like:
apply plugin: "com.android.library"
apply plugin: "kotlin-android"
apply plugin: "kotlin-android-extensions"
apply plugin: "kotlin-kapt"
apply plugin: "de.mannodermaus.android-junit5"
...

android {
    compileSdkVersion 30
    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
...
    }
    testOptions {
        unitTests.all {
            useJUnitPlatform()
        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

...

    androidTestImplementation "androidx.test:runner:1.3.0"
    androidTestImplementation "androidx.test:core:1.3.0"
    androidTestImplementation "androidx.test.ext:junit:1.1.2"
    androidTestImplementation 'io.kotest:kotest-runner-junit5:4.3.1'
    androidTestImplementation 'io.kotest:kotest-assertions-core:4.3.1'
    androidTestImplementation 'io.kotest:kotest-property:4.3.1'
    androidTestImplementation 'io.kotest:kotest-assertions-arrow:4.3.1'
}
and this's what my test configs look like:
The tests also don't allow me to pick a device, which would be expected from an instrumented test
a

alexfacciorusso

11/04/2020, 9:07 AM
Hi Ahmed, Unfortunately at the moment the Android support for Kotest is very experimental. I hope to find some time to fix it completely. In the meantime, you can have a look at the sample project here. We are stuck with a minSdkVersion of
26
because of some dependencies in Kotest not compiling on earlier versions, but that example works for now
😓 1
View count: 9