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

    Hinaka

    10/21/2021, 3:47 PM
    hello everyone, in junit4 I used to do something like this
    class TestClass {
        private val testDispatcher = TestCoroutineDispatcher()
            
        @Before
        fun setup() {
            // provide the scope explicitly, in this example using a constructor parameter
            Dispatchers.setMain(testDispatcher)
        }
        
        @After
        fun cleanUp() {
            Dispatchers.resetMain()
            testDispatcher.cleanupTestCoroutines()
        }
        
        @Test
        fun testFoo() = testDispatcher.runBlockingTest {
            // TestCoroutineDispatcher.runBlockingTest uses `testDispatcher` to run coroutines 
            foo()
        }
    }
    
    fun foo() {
        MainScope().launch { 
            // launch will use the testDispatcher provided by setMain
        }
    }
    and inject that
    testDispatcher
    to any class that need a dispatcher. Can I do the same using kotest, especially with the
    BehaviorSpec
    ?
    s
    l
    • 3
    • 33
  • n

    nikolaymetchev

    10/22/2021, 10:09 AM
    Hello, I don’t know if you are aware but kotest isn’t compatible with the gradle enterprise retry plugin. I filed a bug request with Gradle here. However there doesn’t seem to be a straight forward way of fixing it. Can anybody help? Possibly contribute to Gradle or amend kotest to solve this issue?
    s
    • 2
    • 1
  • l

    LeoColman

    10/23/2021, 6:08 PM
    message has been deleted
    s
    b
    • 3
    • 2
  • d

    dave08

    10/25/2021, 10:25 AM
    Does the kotest gradle plugin support not displaying the stacktrace in failures? I just want to see an overview and then drill in to specific tests that failed...
    s
    • 2
    • 1
  • d

    dave08

    10/25/2021, 10:27 AM
    Also, I get a funny crash:
    > Task :api:kotest
    io.kotest.engine.reporter.TaycanConsoleReporter
    java.lang.ClassNotFoundException: io.kotest.engine.reporter.TaycanConsoleReporter
            at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
            at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
            at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
            at java.base/java.lang.Class.forName0(Native Method)
            at java.base/java.lang.Class.forName(Class.java:315)
            at io.kotest.engine.launcher.ConsoleKt.createConsoleListener(console.kt:21)
            at io.kotest.engine.launcher.MainKt.main(main.kt:28)
    s
    • 2
    • 20
  • c

    christophsturm

    10/25/2021, 10:30 AM
    can kotest tests publish results that are then published together with the test report (for example a pdf or a screenshot)
    s
    • 2
    • 13
  • s

    Sandymcp

    10/25/2021, 3:11 PM
    package sse
    
    import io.kotest.core.spec.style.FunSpec
    import io.kotest.matchers.shouldBe
    import java.io.BufferedReader
    import java.io.StringReader
    
    data class Case<G, W>(val given: G, val want: W)
    
    class SseReaderKoTest : FunSpec({
    
        context("read tag and payload test") {
            withData(
                mapOf(
                    "empty marks end of message" to Case("\n", "" to ""),
                    "event and payload" to Case("event: surprise\n", "event" to "surprise"),
                    "data and payload" to Case("data: surprise\n", "data" to "surprise"),
                    "id and payload" to Case("id: surprise\n", "id" to "surprise"),
                    "comment" to Case(": surprise\n", ":" to ""),
                    "blank comment" to Case(":\n", ":" to ""),
                )
            ) { (given, want) ->
                readTagAndPayload(BufferedReader(StringReader(given))) shouldBe want
            }
        }
    })
    d
    • 2
    • 16
  • s

    Sangmin Lee

    10/26/2021, 7:08 AM
    Hi. I’m trying to improve test performance. Is there a way to get test performance report (or test profiling), which show taken time for an each test and a test phase like build, bean register, run test, … in kotest(or spring test)?
    s
    • 2
    • 1
  • b

    Big Chungus

    11/01/2021, 3:48 PM
    Is there an example of kotest framework mpp setup somewhere?
    j
    s
    • 3
    • 20
  • d

    dave08

    11/02/2021, 3:20 PM
    And the Mxx versions require 1.6? I can't really switch now...
    s
    • 2
    • 9
  • s

    sam

    11/02/2021, 3:24 PM
    Right but in 5.0 you can. I'll double check that there's no changes required from a user perspective
    d
    • 2
    • 59
  • i

    Imran/Malic

    11/03/2021, 1:22 PM
    is there a good alternative of
    Arb<A>.distinct()
    in
    5.0.0.X
    s
    • 2
    • 5
  • e

    Emil Kantis

    11/04/2021, 9:59 AM
    Could we use contracts to help compiler realize
    x
    is not null in this case? Perhaps a specific
    shouldNotBeNull
    matcher required?
    var x: String? = "hello"
    x shouldNotBe null
    x!!.substring(2) shouldBe "he" // !! should not be necessary, since previous assertion checks that it is not null
    m
    • 2
    • 2
  • b

    Big Chungus

    11/04/2021, 10:32 AM
    Could you guys publish v5.0.0 with artefacts for all targets, please. Currently snapshots are missing artefacts for non-testable targets, however it's sstill important to have them as otherwise you can't use kotest in commonMain for projects that also have production sources for untestable targets. Here's an easy escape hatch to cover them all with a single sourceSet https://github.com/mpetuska/klip/blob/master/buildSrc/src/main/kotlin/plugin.library-mpp.gradle.kts#L52
    j
    s
    • 3
    • 18
  • i

    Ivan Pavlov

    11/07/2021, 8:03 AM
    I have a problem with js tests. They don't seem to work and I can't figure what's wrong with my setup. Kotest version is 4.6.2. When I replace my dependencies in commonMain with snapshot dependencies in commonMain from https://github.com/kotest/kotest-examples-multiplatform and add plugin it works fine. But I didn't find any docs about multiplatform plugin for 4.6.2. Am I missing something? I'll attach some info in thread
    s
    • 2
    • 10
  • l

    Lilly

    11/09/2021, 3:12 PM
    Note: Not a Kotest per-se question. Hi I'm new to testing. I would like to share some functions between my local unit tests in my src\test\java folder. What's the right way to do this. I know that for sharing code between unit tests and instrumented tests I can create a commonTest folder and add it to the sourceSets but in this case I only need to share code between unit tests.
    m
    w
    • 3
    • 16
  • p

    Pratik Tandel

    11/10/2021, 8:46 PM
    is there a plan to update kotest’s intellij plugin? https://plugins.jetbrains.com/plugin/14080-kotest does the plugin primarily only work with gradle and what would it take for it to work with bazel?
    ✅ 1
    s
    l
    r
    • 4
    • 23
  • j

    Julian Ostarek

    11/14/2021, 5:51 PM
    How does one get snapshots of the multiplatform plugin for JVM, JS & Native? I can see only subset artifacts on sonatype and I wonder what this is about
    s
    • 2
    • 13
  • c

    charleskorn

    11/14/2021, 8:30 PM
    Has anyone successfully used the latest prerelease version of Kotest (5.0.0.M4) with Kotlin/Native's new memory model (using Kotlin 1.6.0-RC2)? With the new memory model enabled, none of my tests run. I'm using the instructions in https://github.com/JetBrains/kotlin/blob/master/kotlin-native/NEW_MM.md to enable the new memory model.
    s
    • 2
    • 4
  • p

    Peter

    11/15/2021, 3:23 AM
    'java.lang.Throwable io.kotest.assertions.eq.EqKt.eq$default(java.lang.Object, java.lang.Object, boolean, int, java.lang.Object)'
    java.lang.NoSuchMethodError: 'java.lang.Throwable io.kotest.assertions.eq.EqKt.eq$default(java.lang.Object, java.lang.Object, boolean, int, java.lang.Object)'
    this happens when i do
    x().shouldBeSome("y")
    ❌ kotest 4.6.3 io.kotest.extensions:kotest-assertions-arrow:1.1.1
    s
    • 2
    • 45
  • s

    simon.vergauwen

    11/17/2021, 8:01 PM
    Running again, I was a version behind on the multiplatform plugin.
    s
    • 2
    • 1
  • j

    Javier

    11/17/2021, 10:20 PM
    I added JS target to one library and it is failing due SyntaxError caused by Kotest
    s
    • 2
    • 12
  • s

    simon.vergauwen

    11/18/2021, 8:01 AM
    Still same issue with
    5.0.0.RC
    for Kotest and Gradle plugin. https://github.com/nomisRev/Saga/runs/4248416261?check_suite_focus=true#step:4:59
    c
    s
    • 3
    • 2
  • m

    Michael Strasser

    11/18/2021, 8:32 AM
    I am trying to use
    withData
    and
    DescribeSpec
    but I can’t get the tests to be named as I expect. Given a function
    fun messageMap(id: String): Map<String, Message>
    that returns 3 different messages, if I use:
    describe("adds messages") {
        val id = randomId()
        it("sets ID from message") {
            withData(messageMap(id)) { message ->
                Builder.newInstance().addMessage(message).getId() shouldBe id
            }
        }
    }
    The test runs once with title “sets ID from message”. But if I use:
    describe("adds messages") {
        val id = randomId()
        withData(messageMap(id)) { message ->
            it("sets ID from message") {
                Builder.newInstance().addMessage(message).getId() shouldBe id
            }
        }
    }
    The test runs 3 times with titles:
    sets ID from message
    (1) sets ID from message
    (2) sets ID from message
    I expected from the docs that the string keys for the map would be used as test names. I am using Kotest 4.6.3.
    b
    s
    • 3
    • 20
  • d

    Didier Villevalois

    11/20/2021, 11:36 AM
    Hi all, I am willing to use Kotest to test my multi-platform library (targets jvm, js and native). So I have a few questions that I can't fully answer with what I've gathered from the kotest.io documentation website. I hope you'll be able to answer those and I thank you in advance. I figured out that I had to add those dependencies to my
    commonTest
    source-set:
    implementation("io.kotest:kotest-framework-engine:$kotestVersion")
                    implementation("io.kotest:kotest-framework-datatest:$kotestVersion")
    I also had to add this dependencies to my
    jvmTest
    source-set, to have the tests picked up by JUnit:
    implementation("io.kotest:kotest-runner-junit5:$kotestVersion")
    1. What are the corresponding ways to have tests picked up for JS and Native targets? 2. It seems to me that
    kotest-framework-datatest
    is not yet supported on Native target? (cf. https://search.maven.org/search?q=g:io.kotest%20kotest-framework-datatest) Will this be supported at some point? (I don't seem to see anything in its source code https://github.com/kotest/kotest/tree/master/kotest-framework/kotest-framework-datatest that would prevent it from running on Native, except the fact that the target is not defined in the Gradle build file. Or am I missing something?)
    s
    • 2
    • 5
  • d

    Didier Villevalois

    11/20/2021, 12:47 PM
    Yet another question, is it possible to configure the individual data tests (
    withData
    ) with a specific timeout.
    s
    j
    • 3
    • 9
  • r

    Rob Elliot

    11/24/2021, 4:39 PM
    Just added
    kotest-extensions-spring:1.0.1
    to my maven project (using surefire to run
    kotest-framework-api-jvm:4.6.3
    ) and with no code changes it stopped finding any of my existing specs. No errors logged, it just silently stops working.
    s
    • 2
    • 42
  • l

    Lilly

    11/24/2021, 4:43 PM
    I'm trying to access an internal class in main from a test class but it's not visible. Is this the correct behaviour? I'm just wondering because some SO threads claim it's possible to access internal class from test class. It's an android library project if it matters
    s
    • 2
    • 5
  • s

    sam

    11/24/2021, 6:48 PM
    Full docs to follow after thanksgiving
    m
    • 2
    • 5
  • t

    thanksforallthefish

    11/25/2021, 8:34 AM
    how can I get spring extension 1.1.0? it seems to exist (https://github.com/kotest/kotest-extensions-spring) but it is not on maven central (https://search.maven.org/search?q=a:kotest-extensions-spring%20AND%20g:io.kotest.extensions)
    e
    s
    • 3
    • 7
Powered by Linen
Title
t

thanksforallthefish

11/25/2021, 8:34 AM
how can I get spring extension 1.1.0? it seems to exist (https://github.com/kotest/kotest-extensions-spring) but it is not on maven central (https://search.maven.org/search?q=a:kotest-extensions-spring%20AND%20g:io.kotest.extensions)
e

Emil Kantis

11/25/2021, 8:36 AM
Not sure if release is pending for some reason.. I grabbed the snapshot build for now
t

thanksforallthefish

11/25/2021, 8:41 AM
from https://oss.sonatype.org/content/repositories/snapshots/io/kotest/extensions/kotest-extensions-spring/1.1.0.16-SNAPSHOT/ right?
yes, ofc, it is in the official docs, my eyes just got crossed between 1.0.1 and 1.1.0.16, somehow read 1.0.1.16 three hundred times 😄
🤣 1
s

sam

11/25/2021, 12:11 PM
It was pending 5.0
I guess i pushed the changelog too soon
e

Emil Kantis

11/25/2021, 2:54 PM
@thanksforallthefish 1.1.0 is available now 🙂
🔥 2
t

thanksforallthefish

11/25/2021, 2:54 PM
so fast, awesome 🙂
View count: 2