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

    dave08

    04/27/2021, 1:06 PM
    It seems like the Kotest intellij plugin's test browser ignores the context blocks in DescribeSpec...
    w
    s
    • 3
    • 16
  • d

    dave08

    04/29/2021, 9:19 AM
    Thanks for the plugin fix! Just wondering if there's any way the test browser could also work for test factories? (I have a separate file I declare the function I use to import into integration/unit test modules... that function doesn't seem to have such a view)
    s
    • 2
    • 4
  • j

    Jerry Preissler

    04/29/2021, 5:41 PM
    The plugin was updated today to 1.1.34-IC-202, kotest_version=4.4.3
    s
    • 2
    • 52
  • j

    José González Gómez

    04/30/2021, 11:27 AM
    Hi, I'm having a problem with
    kotest
    and
    Android Studio
    in a Kotlin multiplatform project. After adding the
    kotest
    dependencies to
    build.gradle.kts
    and reloading the project I get the following warning (not even an error):
    Warning:<i><b>project ':partnerSDK': Unable to build Kotlin project configuration</b>
    Details: org.gradle.internal.resolve.ArtifactNotFoundException: Could not find kotest-runner-junit5-4.4.3-samplessources.jar (io.kotest:kotest-runner-junit5:4.4.3).
    Searched in the following locations:
        <https://repo.maven.apache.org/maven2/io/kotest/kotest-runner-junit5/4.4.3/kotest-runner-junit5-4.4.3-samplessources.jar></i>
    This seems to cause
    Android Studio
    to stop working, and I'm no longer able to use code completion, or even run unit tests. This makes test creation extremely painful. If I manually create a test I'm able to run it using
    ./gradlew test
    , so this is clearly not a problem with my configuration or Gradle... Has anybody faced this problem? Do you know how to solve it?
    w
    m
    • 3
    • 13
  • l

    LeoColman

    05/02/2021, 3:51 PM
    Maybe some sort of extension function
    a
    d
    s
    • 4
    • 16
  • j

    José González Gómez

    05/03/2021, 7:45 AM
    Is it possible to use
    kotest
    in a Kotlin Multiplatform Mobile project? I have included the following dependencies in the shared project:
    val kotestVersion = "4.4.0"
    kotlin {
        sourceSets {
            val commonTest by getting {
                dependencies {
                    implementation("io.kotest:kotest-runner-junit5:$kotestVersion")
                    implementation("io.kotest:kotest-assertions-core:$kotestVersion")
                    implementation("io.kotest:kotest-property:$kotestVersion")
                }
            }
        }
    }
    but this fails when trying to build the project because there is no
    ios_x64
    variant of
    kotest-runner-junit5
    . Android Studio fails while reloading the project trying to find
    kotest-runner-junit5-4.4.0-samplessources.jar
    and
    ./gradlew build
    explicitly fails due to the missing
    ios_x64
    variant not found.
    t
    m
    s
    • 4
    • 7
  • m

    Mikhail Buzuverov

    05/05/2021, 3:52 AM
    Hello all! Could you let me a bit more details about running kotest in multiplatform project (JVM + JS)? According documentation I added into build.gradle.kts:
    val commonTest by getting {
                dependencies {
                    implementation(kotlin("test-common"))
                    implementation(kotlin("test-annotations-common"))
                    implementation("io.kotest:kotest-framework-engine:$kotestVersion") //<< This dependency
                }
            }
    And wrote test:
    class OperationResultSerializationTest: FunSpec({
    
        val json = Json {
            serializersModule = SerializersModule {
                polymorphic(Any::class) {
                    subclass(TestPayload::class)
                }
            }
        }
    
        test("success action result should be serialized and deserialized") {
            val actionSuccessJson = json.encodeToString<ActionResult>(ActionSuccess)
            val actionSuccessDeserialized = json.decodeFromString<ActionResult>(actionSuccessJson)
    
            actionSuccessDeserialized shouldBe null //<<Should FAIL here (intentionally)
        }
    })
    But when I run it using gradlew check I get in IDEA just row:
    s
    a
    • 3
    • 20
  • s

    sam

    05/05/2021, 1:27 PM
    Kotest 4.5 has been released. Feel free to share. https://kotest.io/docs/changelog.html
    🍾 4
    🎉 8
    👍 5
    :kotlin-intensifies: 1
    p
    d
    +2
    • 5
    • 34
  • a

    Animesh Sahu

    05/08/2021, 4:44 PM
    Why doesn't kotest support other K/N platforms like
    linuxArm32Hfp
    ,
    linuxMips32
    ,
    mingwX86
    ? Is it due to kx.coroutines does not support it? 👀
    b
    • 2
    • 6
  • h

    huehnerlady

    05/10/2021, 8:01 AM
    is there a reason why
    kotest-extensions-spring
    is not released with 4.5.0 in maven-central? https://mvnrepository.com/artifact/io.kotest/kotest-extensions-spring I ran into the problem as I have a group-wide versioning and
    kotest-extensions-spring
    cannot be found in 4.5.0 😅 Is that a separately released lib?
    ☑️ 1
    w
    • 2
    • 6
  • w

    wasyl

    05/10/2021, 11:16 AM
    I’m wondering why I don’t see compilation errors for assertions where types don’t match, for example
    5 shouldBe "5"
    . There’s no error shown, even though the signature would force the right-hand parameter to be a assignable to the left-hand one (
    infix fun <T, U : T> T.shouldBe(expected: U?)
    ), or so I thought. Is this expected? It’s pretty annoying when refactoring code, because tests still compile but fail in runtime
    j
    s
    • 3
    • 63
  • j

    James Eschner

    05/10/2021, 9:27 PM
    Hello all. I updated to the latest version of kotest (4.5) and kotlin (1.5) and am seeing the following:
    Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
        /Users/jameseschner/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.5.0/65fbc439df2e4aad1f3769762d54534f1b564090/kotlin-stdlib-jdk8-1.5.0.jar (version 1.5)
        /Users/jameseschner/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.5.0/f61904618ea7be07a66e0545ffe8dc2c70a19b77/kotlin-stdlib-jdk7-1.5.0.jar (version 1.5)
        /Users/jameseschner/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.0/29dae2501ca094416d15af0e21470cb634780444/kotlin-stdlib-1.5.0.jar (version 1.5)
        /Users/jameseschner/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.5.0/4080d69efca5e39e9b4972f125e40f1607bd6460/kotlin-stdlib-common-1.5.0.jar (version 1.5)
        /Users/jameseschner/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-script-runtime/1.4.31/183616b52cfb8ddaa8a2a15bf926e87dfcddcde3/kotlin-script-runtime-1.4.31.jar (version 1.4)
    Looks like kotest is pulling in 1.4.31:
    +--- io.kotest:kotest-runner-junit5 -> 4.5.0
    |         +--- io.kotest:kotest-framework-engine:4.5.0
    |         |    \--- io.kotest:kotest-framework-engine-jvm:4.5.0
    |         |         +--- org.jetbrains.kotlin:kotlin-script-runtime:1.4.31
    Is kotest planning on moving to 1.5 soon? * Not a Contribution *
    s
    • 2
    • 1
  • d

    dave08

    05/13/2021, 10:21 AM
    Is it intentional that when using
    it("some test description")
    without the trailing lambda, the test should pass? Why should that behaviour be needed? I would have thought that at least for TDD -- it should fail... I use this form just to outline the tests I need to write, but one might easily forget to implement them if they pass...
    s
    • 2
    • 4
  • d

    dave08

    05/13/2021, 10:24 AM
    Also, funny that ignored tests don't appear in IDEA U....
    s
    j
    • 3
    • 9
  • w

    wasyl

    05/13/2021, 7:22 PM
    Is there any way to run the tests such that new spec instance is created for every container that contains tests, but all the tests inside are executed on that one instance? My motivation is that the assertions shouldn’t do any side effects, and so it’s a bit wasteful to repeat the entire setup for each test. So, I’d like this:
    DescribeSpec({
      describe("a") {
        println("a")
    
        describe("b") {
          println("b")
    
          it("check 1") { println("1") }
          it("check 2") { println("2") }
        }
    
        describe("c") {
          println("c")
    
          it("check 1") { println("1") }
          it("check 2") { println("2") }
        }
      }
    })
    to print
    a // first instance
    b
    1
    2
    a // second instance
    c
    1
    2
    s
    c
    • 3
    • 85
  • w

    wasyl

    05/14/2021, 12:29 PM
    Starting a thread about memory usage since the previous one is long enough 🙂
    s
    c
    • 3
    • 131
  • w

    wasyl

    05/16/2021, 12:19 PM
    Another one 😄 https://github.com/kotest/kotest/commit/a0ea126434401074dc8d1839fb986c23a74780c1 this commit didn’t really change anything because I was running tests with Gradle, and this discovery path is not even hit — Gradle (Junit?) passes all requested tests classes already, Kotest just filters them to keep Spec instances. The 4GB of memory that ClassGraph takes is triggered by
    detectConfig()
    . Disabling jar scanning for it is not reasonable, because jars may provide listeners. So while config discovery is pretty useful, would you consider some other mechanism for that? I know that scanning can be disabled, but then modules wouldn’t be able to provide useful listeners (I think I even requested discovery at one point, to avoid having to declare a merged project config in each module). One thing that comes to mind is allowing everything that can be AutoScanned now to be provided via ServiceLoaders. Locally I just hardcoded our listeners and got that peak memory down from 4GB to 1GB. Bottom line: ClassGraph has significant memory impact, at least with larger projects. It’d be nice to have a way to completely bypass it. Btw in addition to memory usage, it also spawns several threads (in my case 18!) that it never releases.
    s
    • 2
    • 33
  • j

    Jonathan Olsson

    05/17/2021, 7:11 PM
    Are there any future plans to extend
    io.kotest:kotest-property
    with stateful testing? 🙂
    s
    d
    • 3
    • 23
  • c

    christophsturm

    05/18/2021, 11:42 AM
    the docs for stringspec state that it does not support nested tests. is that still true?. https://github.com/kotest/kotest/blob/master/doc/styles.md#string-spec
    d
    s
    • 3
    • 50
  • d

    dave08

    05/18/2021, 1:31 PM
    What's the best way to generate a base64 token with Arb?
    s
    • 2
    • 12
  • d

    dave08

    05/18/2021, 1:56 PM
    Should I make an Arb for each one using a function that takes the
    entity1Id
    as a parameter, or is there a better way?
    s
    • 2
    • 8
  • d

    dave08

    05/18/2021, 2:26 PM
    How can I ensure that
    Arb.set
    or
    Arb.list
    generates unique entries by my entity id?
    s
    • 2
    • 11
  • g

    Gopal S Akshintala

    05/19/2021, 7:53 AM
    Has anyone faced this error with latest Kotest: 4.6.0 with Gradle 7.0, gradle-jvm:16, Kotlin: 1.6, Java: 16
    Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
        class io.kotest.core.test.TestContext, unresolved supertypes: kotlinx.coroutines.CoroutineScope
    Adding -Xextended-compiler-checks argument might provide additional information.
    c
    s
    • 3
    • 26
  • d

    dave08

    05/19/2021, 10:49 AM
    Will there be any replacement for Arb.distinct and distinctBy?
    s
    m
    • 3
    • 21
  • d

    dave08

    05/19/2021, 11:42 AM
    Is there any way to use one arb's result to feed the function params for another arb and make a pair out of them (arb1, arb2 cartesian product)?
    s
    m
    • 3
    • 27
  • d

    dave08

    05/19/2021, 12:08 PM
    Any reason why
    fun <A : Any> Arb.Companion.choose(a: Pair<Int, A>, b: Pair<Int, A>, vararg cs: Pair<Int, A>): Arb<A>
    is
    A: Any
    ? It seems like it can't choose from a null?
    s
    • 2
    • 8
  • d

    dave08

    05/20/2021, 12:07 PM
    This is a very nice feature in jqwik: https://jqwik.net/docs/current/user-guide.html#collecting-and-reporting-statistics also the way assumptions return an error if too many possibilities were skipped: https://jqwik.net/docs/current/user-guide.html#assumptions and in general, having some stats printed like there would add tons of value to property testing in kotest... it would make it much easier to make tests.
    j
    s
    • 3
    • 27
  • s

    Sourabh Rawat

    05/21/2021, 8:11 AM
    I am trying to test a grpc spring boot service. Getting
    No qualifying bean of type 'org.lognet.springboot.grpc.autoconfigure.GRpcServerProperties'
    What am I missing?
    t
    • 2
    • 4
  • m

    Mark Allanson

    05/21/2021, 9:33 AM
    Is there a guide anywhere for using mockk and kotest together? I am trying to convert some tests that use
    @Mock
    etc... annotations with `MockKAnnotations.init(this, relaxUnitFun = true)`` and haven't found a good way of doing it yet. I have been using
    BehaviourSpec
    to implement the tests
    d
    s
    • 3
    • 9
  • d

    dave08

    05/23/2021, 12:41 PM
    Another little point... it's a bit confusing to have the CodePoints in the same
    Arb
    as the actual arbitraries... maybe they should be in a
    CodePoint
    companion object?
    s
    • 2
    • 31
Powered by Linen
Title
d

dave08

05/23/2021, 12:41 PM
Another little point... it's a bit confusing to have the CodePoints in the same
Arb
as the actual arbitraries... maybe they should be in a
CodePoint
companion object?
s

sam

05/23/2021, 12:45 PM
you mean Arb.Codepoints.foo ?
d

dave08

05/23/2021, 12:46 PM
No, just Codepoint.foo... the Arb would just make the line longer...
s

sam

05/23/2021, 12:47 PM
so just a top level object
All arbs are currently defined on Arb, for easy discoverability
d

dave08

05/23/2021, 12:50 PM
My point is that they usually are used in combination with Arb.string(..., CodePoint.XXX), although they are Arbs themselves, I wonder if anyone uses them as such. So they could have their own "namespace" to indicate what is available to Arb.string, and they won't interfere with the real Arbs.
s

sam

05/23/2021, 12:51 PM
I see your point, perhaps typealiases ?
d

dave08

05/23/2021, 12:51 PM
My concern is code complete...
s

sam

05/23/2021, 12:52 PM
you want to de-clutter code complete ?
d

dave08

05/23/2021, 12:53 PM
Yeah, and make it clearer what options are available in the two contexts. I don't think a typealias would help, but I guess that deprecated CodePoints on Arb would help migrating and I'd suppose the IDE is smart enough to deprioritize deprecated things.
s

sam

05/23/2021, 12:54 PM
You're probably right that they're never used outside of strings.
If you want to move them to a new top level object, and put in deprecated typealiases for backwards compatbility then I would merge that PR
👍🏼 1
d

dave08

05/23/2021, 12:59 PM
Maybe adding a companion object to CodePoint itself?
And then making them extension functions off it?
s

sam

05/23/2021, 1:00 PM
Yes that seems like a good approach.
d

dave08

05/23/2021, 1:33 PM
It doesn't seem that a typealias can be made as an extension function off Arb.Companion?
I think I might have to leave the original functions as deprecated to delegate to the new ones.
s

sam

05/23/2021, 1:34 PM
Ah ok well that works yeah
d

dave08

05/23/2021, 1:35 PM
In the meantime, I might as well also replace the deprecated Char.toInt() with Char.code?
(in codepoint.kt, I mean)
s

sam

05/23/2021, 1:35 PM
Only if its not 1.5 only
d

dave08

05/23/2021, 1:36 PM
Oh, you're not using any 1.5 in the newer versions? I guess I'll leave them then.
s

sam

05/23/2021, 1:38 PM
Its compiled against 1.5
But we don't want to force users off 1.4
Saying that actually 5.0 will be 1.5 only
So yeah change it
👍🏼 1
d

dave08

05/23/2021, 2:30 PM
Funny, I tried running StringArbTest, but the IDE couldn't find
a.codePoints()
?
But the tests passed, so I guess it's a cache problem.
I should do the PR against the master branch?
s

sam

05/23/2021, 2:51 PM
Yes
d

dave08

05/23/2021, 2:51 PM
https://github.com/kotest/kotest/pull/2283
s

sam

05/23/2021, 2:59 PM
looks good
View count: 6