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

    Mikhail Galanin

    02/03/2021, 1:00 PM
    Hi there, I just noticed that
    io.kotest.core.datatest.NamesKt#isStable(kotlin.reflect.KType)
    return false, when the parameter is enum class. Is it expected?
    a
    • 2
    • 2
  • w

    wasyl

    02/04/2021, 8:59 PM
    I have a super weird case, somewhat related to Kotest but I’m not sure really. Let’s say I have a class
    Foo
    and a factory which always returns the same value as long as the previous one is still referenced:
    class Foo
    
    class FooFactory {
    
        var fooRef: WeakReference<Foo>? = null
        
        fun get() = fooRef?.get() ?: Foo().also { fooRef = WeakReference(it) }
    }
    So far so good. Now I have spec which should assert that the objects are in memory as expected. This overall might be tricky because GC is not very deterministic, but it’s stable enough:
    class TestSpec : DescribeSpec() {
    
        private val fooFactory = FooFactory()
    
        init {
            describe("foo") {
                var foo: Foo? = fooFactory.get()
                // println(foo)
    
                describe("bar") {
                    gc()
                    fooFactory.fooRef?.get() shouldNot beNull()
    
                    foo = null
                    gc()
                    fooFactory.fooRef?.get() should beNull()
    
                    it("should do something") {
                        println("Done")
                    }
                }
            }
        }
    
        override fun isolationMode() = IsolationMode.InstancePerLeaf
    }
    And now the tricky part: if the
    println(foo)
    is commented out, the test works. But if it’s not, then the test fails at the
    should beNull()
    line. Apparently something is holding it. I checked in IJ’s memory tool and it looks like it’s just a variable being kept, but I have no clue why and how this would happen. Also I expect that with
    InstancePerLeaf
    this entire thing is executed just once anyway, as there’s only one leaf. Any ideas?
    s
    l
    • 3
    • 47
  • b

    Big Chungus

    02/04/2021, 10:27 PM
    Hi guys, with the release of 1.4.30 are you any closer of supporting js ir?
    s
    l
    j
    • 4
    • 21
  • w

    wasyl

    02/05/2021, 2:32 PM
    Have there been any changes to exceptions matchers in 4.4.0? Some of our tests started failing and it turns out previously the exceptions that we compared didn’t have matching
    cause
    . Is there an issue I can read to see what’s changed exactly?
    s
    • 2
    • 21
  • s

    sam

    02/06/2021, 7:08 PM
    Would appreciate any feedback on https://github.com/kotest/kotest/issues/2065
    w
    • 2
    • 5
  • h

    Hugo Martins

    02/07/2021, 5:16 PM
    Hey!. I'm facing an issue while trying to work on https://github.com/kotest/kotest/issues/2011 and honestly I thought someone here would be able to help. 😅 When opening
    kotest
    in Intellij, and adding a new module under
    kotest-extensions
    (e.g.
    io.kotest.extensions.htmlreporter
    ), I can't for the life of me find a way to import
    io.kotest.core
    . I'm sure this is probably something obvious that I'm missing but I've tried a couple different ways and can't seem to understand what...if anyone has any idea, I'd be extremely thankful. You can see the code (2 files) I added here:https://github.com/caramelomartins/kotest/tree/master/kotest-extensions/kotest-extensions-htmlreporter. Thanks!
    s
    • 2
    • 25
  • t

    tseisel

    02/08/2021, 8:42 AM
    Does KoTest has support for virtual time in tests ? I'm testing a component that uses
    delay
    and I'd like to check that at least X seconds has elapsed between 2 operations.
    TestCoroutineDispatcher
    from
    kotlinx-coroutines-test
    has this capability but I can't find a way to use it with
    StringSpec
    .
    s
    • 2
    • 5
  • s

    snowe

    02/10/2021, 12:32 AM
    why does this not work the way I would expect?
    d
    s
    • 3
    • 3
  • s

    snowe

    02/10/2021, 12:33 AM
    for the first, the tests aren't nested and so when they start to repeat through the inner loop on the second outer loop, I get 'duplicate' test name errors. but if I create that test internally, now there are two tests with that name. Here is a demonstration of the issue by just adding a prefix to the test
    s
    • 2
    • 26
  • m

    mitch

    02/10/2021, 8:02 PM
    @sam do you still recall our convo about edgecases missing when there's one arb with empty edgecases? i'd be inclined to look into fixing that in the next few days. would this be the right time for me to start looking at it or do i wait until 4.5?
    s
    • 2
    • 141
  • m

    mitch

    02/13/2021, 9:34 AM
    qq is there a way to rerun build on a pr branch?
    • 1
    • 3
  • d

    dave08

    02/15/2021, 3:06 PM
    Hi! If I need to configure an instance of a testcontainer for postgres, where whould I do that? It seems like
    Startable.perProject(...)
    takes a name param, but doesn't work for a customized container...
    s
    t
    • 3
    • 39
  • d

    dave08

    02/15/2021, 3:07 PM
    Also, do listeners get run in the order they are declared? (I need to get the db running before Micronaut's extension starts up...)
    s
    • 2
    • 1
  • w

    why

    02/16/2021, 12:52 PM
    Hi.. I keep getting this error after I updated to Kotlin 1.4.30, while trying to use this dependency
    io.kotest:kotest-assertions-core:
    in commonTest:
    Compilation failed: Backend Internal error: Exception during IR lowering
    File being compiled: /Users/runner/work/kotest/kotest/kotest-assertions/kotest-assertions-core/src/commonMain/kotlin/io/kotest/matchers/collections/decreasing.kt
    The root cause java.lang.AssertionError was thrown at: org.jetbrains.kotlin.ir.overrides.FakeOverrideBuilderStrategy.fakeOverrideMember(IrOverridingUtil.kt:43)
    
     * Source files: 
     * Compiler version info: Konan: 1.4.30 / Kotlin: 1.4.30
     * Output kind: STATIC_CACHE
    s
    • 2
    • 3
  • d

    dave08

    02/16/2021, 12:59 PM
    I'm getting a very puzzling problem... even though I added the Micronaut extension, it seems like it's just being ignored...
    ~~~ Kotest Configuration ~~~
    ...
    -> Extensions
      - io.micronaut.test.extensions.kotest.MicronautKotestExtension
      - io.kotest.engine.extensions.SystemPropertyTagExtension
      - io.kotest.core.extensions.RuntimeTagExtension
      - io.kotest.engine.extensions.RuntimeTagExpressionExtension
    -> Listeners
      - io.micronaut.test.extensions.kotest.MicronautKotestExtension
      - beforeAfterAllListener$1
    s
    • 2
    • 9
  • r

    Rob Elliot

    02/16/2021, 2:10 PM
    Just out of curiosity - how painful is it keeping the plugin working with each new IntelliJ version? Are we talking minutes, hours, days or weeks to get a version out that supports an EAP?
    s
    • 2
    • 18
  • p

    Paul Griffith

    02/16/2021, 11:56 PM
    Am I missing a trick to test Ktor (clients)? I'm using
    MockEngine
    (from ktor) in a
    FunSpec
    , and the code is definitely being run (I see the failure message being logged) but the actual test passes
    s
    • 2
    • 6
  • m

    Marius Kotsbak

    02/17/2021, 3:59 PM
    Hi! Why are versions of "kotest-core-jvm" lagging behind "kotest-assertions-core-jvm" etc?
    s
    • 2
    • 13
  • b

    Big Chungus

    02/17/2021, 4:08 PM
    Is kotest available for native targets yet?
    s
    • 2
    • 4
  • e

    Eric Ampire [MOD]

    02/18/2021, 6:48 AM
    Hello, I have just started using kotest, and I have noticed that it’s not possible to run all test in one time, the kotest plugin show only tests available in the selected class, and when I tried to run all tests through the test folder as with junit I got this message “No tests found for given includes”, how can I fix that ?
    s
    • 2
    • 9
  • r

    rpillay

    02/19/2021, 6:20 AM
    I think we should revisit this as a topic of discussion - At the moment, this would be a blocker to upgrading my kotest version, but more importantly its a bit of a blocker to properly setting up edgecases - theres an incentive to just ignore them so that our tests don't balloon out into the hundreds of thousands of iterations. What do you think @sam and @mitch?
    m
    s
    • 3
    • 55
  • a

    Andrei Casu Pop

    02/24/2021, 7:30 PM
    Hello, Does anyone have a very minimal build.gradle.kts file for running kotest on multiplatform jvm/js? I tried following the get started guide but the js dependency cannot be resolved by gradle.
    implementation 'io.kotest:kotest-framework-engine:$version'
    s
    • 2
    • 7
  • p

    Peter

    03/03/2021, 10:43 PM
    hi @sam - have you seen this with coroutines 1.4.3 (released this morning):
    java.lang.NoSuchMethodError: 'java.lang.Object kotlinx.coroutines.DelayKt.delay-p9JZ4hM(double, kotlin.coroutines.Continuation)'
    	at io.kotest.assertions.timing.EventuallyKt.eventually(eventually.kt:118)
    	at io.kotest.assertions.timing.EventuallyKt$eventually$10.invokeSuspend(eventually.kt)
    s
    w
    • 3
    • 9
  • p

    Paul Woitaschek

    03/04/2021, 3:30 PM
    @sam By updating to kotlin 1.4.30 and using the
    watchos
    shortcut, you have effectively removed watchosx86. Can you remove the shortcut and add the separate watchos targets manually?
    s
    c
    • 3
    • 32
  • p

    Peter

    03/05/2021, 4:19 PM
    having a little trouble getting tests to run in sub sub project, eg: https://docs.gradle.org/current/userguide/intro_multi_project_builds.html#sec:multiproject_build_and_test … it would be
    :services:shared:test
    s
    w
    • 3
    • 31
  • b

    bbaldino

    03/05/2021, 6:18 PM
    I’ve got a test structured something like:
    context("when starting a Foo") {
        context("and thing A happens") {
            should("throw an error") {
            }
        }
        context("and thing B happens") {
            should("throw an error") {
            }
        }
    }
    and when I get a failure, in the junit output I just get:
    "should throw an error"
    for context, which is ambiguous between those 2 cases. Is there a way to get the full context “tree” when a failure happens?
    s
    • 2
    • 70
  • s

    snowe

    03/05/2021, 7:58 PM
    test is simple
    class MathKtTest : FreeSpec({
        data class Points(
            val apr: String,
            val term: Int
        )
        "calculate discount factor" - { 
            forAll(
                row("1", 12)
            ) { (apr, term) ->
                val D = calculateDiscountFactor(BigDecimal(apr), term)
                assertEquals(BigDecimal("75.6813"), D)
            }
        }
    })
    method is a top level method
    fun calculateDiscountFactor(apr: BigDecimal, term: Int) :BigDecimal{
        val r = apr
        val n = 12 * term
        val denominator = { ((BigDecimal.ONE + apr).pow(n)) - BigDecimal.ONE }
        val numerator = { r * (BigDecimal.ONE + r).pow(n) }
        return numerator() / denominator()
    }
    kotest version 4.4.1, plugin version
    1.1.30-IC-2020.3
    kotlin version 1.3.72
    w
    s
    • 3
    • 13
  • d

    dave08

    03/07/2021, 2:03 PM
    Is there a way to only enable a project extension if actually needed in one of the test classes being run? I need some testcontainers to come up but only for certain tests, and stay alive for other classes that might need them.
    s
    • 2
    • 18
  • m

    Mao

    03/08/2021, 5:47 AM
    Hi It seems
    kotest-extensions-robolectric
    didn’t release with the latest version
    4.4.x
    but stay at
    4.3.2
    . Is there any plan to bump it to the latest version? https://mvnrepository.com/artifact/io.kotest/kotest-extensions-robolectric-jvm
    s
    • 2
    • 1
  • m

    mitch

    03/09/2021, 1:22 PM
    @sam qq relaying a q from a colleague. do you have a suggestion on how can we register listeners to say checkAll per scope e.g. nested in a context? Right now we've been using explicit function calls / passing various explicit proptestconfig that carries a listener with it. Curious if you have a better idea around that
    s
    • 2
    • 21
Powered by Linen
Title
m

mitch

03/09/2021, 1:22 PM
@sam qq relaying a q from a colleague. do you have a suggestion on how can we register listeners to say checkAll per scope e.g. nested in a context? Right now we've been using explicit function calls / passing various explicit proptestconfig that carries a listener with it. Curious if you have a better idea around that
s

sam

03/09/2021, 1:22 PM
Not sure I understand the ask. Do you have an example ?
m

mitch

03/09/2021, 1:27 PM
we’ve been doing
test("something") {
    checkAll(
        defaultPropTestConfig().withListeners(beforeAfterListener),
        arbFoo,
        arbBar
    ) { foo, bar ->
       ...
    }
}

fun PropTestConfig.withListeners(vararg listeners: PropTestListener): PropTestConfig = ...
which works
s

sam

03/09/2021, 1:28 PM
and you'd rather register the listener somewhere global than adding it to the prop test config ?
m

mitch

03/09/2021, 1:29 PM
the ask was if it’s possible to do this (we use funspec)
context("foo") {
    beforeProperty {
       ...
    }
    
    test(...) { 
       etc...
    }
}
s

sam

03/09/2021, 1:32 PM
the property test library can't rely on special things in the framework, or it would only be usable from kotest ....but I think we could possibly make this work.
checkAll is a suspend method so it has access to the coroutine context
hmmm but it would need to completely surround the test
I think with some trickery we could make lifecycle methods on property testing work from the DSL of kotest. I need to think about it a little more.
https://github.com/kotest/kotest/issues/2161
🎖️ 1
m

mitch

03/09/2021, 1:38 PM
yeah, i was looking around the codebase, lifting checkAll above the test or somehow implicitly injecting a container scope to checkAll but might be quite a massive change.. something like this?
ContainerScope.checkAll(...)
oh wow thanks Sam!
s

sam

03/09/2021, 1:38 PM
I like your syntax of the beforeProperty block
but it needs to somehow register a lambda that's available to nested forAll / checkAlls
m

mitch

03/09/2021, 1:39 PM
hmm yeah tricky
s

sam

03/09/2021, 1:39 PM
it's straight forward to have the forAll / checkAlls look for a well known attribute in the coroutine context
but contexts are immutable, so the registration part would need to add it and return a new context, like how withContext does
If we allow scopes to register test case extensions, then those are capable of changing contexts
anyway I'll have a play soon, this is a good idea
m

mitch

03/09/2021, 1:41 PM
thanks!
@sam i think this is related https://github.com/kotest/kotest/issues/2171#issue-835864697
View count: 4