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

    Shalom Halbert

    12/13/2020, 7:01 PM
    Hey folks, what are the differences between Kotest and Spek?
    s
    • 2
    • 4
  • t

    tieskedh

    12/15/2020, 2:34 PM
    I believe this code works correctly. In that case, maybe it's something to add in the lib? If there is a better way, or if there is a bug, which one?
    open class FlatmapCombinedShrinker2<Original, value1, value2>(
        private val select1: (Original) -> value1,
        private val shrinker1: Shrinker<value1>,
        private val select2: (Original) -> value2,
        private val shrinker2: Shrinker<value2>,
        private val composer: Original.(value1, value2) -> Original
    ) : Shrinker<Original> {
        override fun shrink(value: Original): List<Original> {
            val hasShrinks = BooleanArray(2) { true }
    
            val value1 = select1(value)
            val shrinks1 = shrinker1.shrink(value1).ifEmpty {
                hasShrinks[0] = false
                listOf(value1)
            }
    
            val value2 = select2(value)
            val shrinks2 = shrinker2.shrink(value2).ifEmpty {
                hasShrinks[1] = false
                listOf(value2)
            }
    
            return if (hasShrinks.any { it }) {
                shrinks1.flatMap { val1 ->
                    shrinks2.map { val2 ->
                        value.composer(val1, val2)
                    }
                }
            } else emptyList()
        }
    }
    s
    • 2
    • 18
  • m

    Mervyn McCreight

    12/15/2020, 3:52 PM
    Hey 🙂 I’m currently fiddling around with
    property-based-testing
    in Kotest. I want to create a custom
    arbitrary
    based on already defined
    arbitraries
    . I found this page in the documentation about it: https://kotest.io/docs/proptest/custom-generators.html#arbitrary In the documentation there is a code snippet about doing it:
    val personArb = arbitrary { rs ->
       val names = Arb.string().values(rs)
       val ages = <http://Arb.int|Arb.int>().values(rs)
       names.zip(ages).map { (name, age) -> Person(name.value, age.value) }
    }
    The concept is clear, but the function
    values(RandomSource)
    is deprecated. What am I supposed to use as an alternative in this case? Would it be
    generate(RandomSource)
    ? The replacement description is not really applicable for this particular case I think. Using
    samples(RandomSource)
    seems wrong, because I think it makes sense to keep the edge-cases of the arbs here 🤔 .
    s
    • 2
    • 12
  • b

    bbaldino

    12/16/2020, 12:21 AM
    Using
    4.3.1
    , and notice that when running tests in maven and one fails, I only get the string from the bottom-most
    should
    in the report, which makes it ambiguous. Is there a way to get the entire test "path" string to show up there? I.e. the stuff from the surrounding
    context
    blocks?
    s
    s
    • 3
    • 2
  • b

    bbaldino

    12/16/2020, 11:09 PM
    I'm running into an issue where I'm using
    runBlockingTest
    and
    advanceUntilIdle
    and I think it's fooling kotest into thinking the test has timed out
    s
    s
    • 3
    • 38
  • d

    dave08

    12/17/2020, 11:37 AM
    Is it just my internet connection, or is kotest.io site just VERY slow (maybe because of popularity 🙂)?
    m
    w
    s
    • 4
    • 11
  • c

    christophsturm

    12/17/2020, 12:07 PM
    what right click menu are you using? I’m using IDEA and not AS, but if i select run from the project explorer context menu it asks me what test runner i want to use.
    d
    • 2
    • 4
  • s

    Shalom Halbert

    12/17/2020, 1:20 PM
    Added the plugin, but running individual tests using a gutter icon doesn’t work. It shows the test passes without running anything. Is there something wrong with my setup? Happy to provide additional details.
    w
    s
    • 3
    • 57
  • d

    dave08

    12/20/2020, 2:05 PM
    Seems like this issue went stale after implementing Robolectric support, so it's not too clear...: https://github.com/kotest/kotest/issues/189
    s
    s
    • 3
    • 5
  • s

    sam

    12/21/2020, 11:00 PM
    Lol indeed. You should revert to the previous version for now
    t
    • 2
    • 9
  • k

    kopper

    12/22/2020, 8:31 AM
    In property based tests, when I set
    kotest.proptest.default.iteration.count
    to something low, e.g.
    1
    , plenty of my tests fails because
    computeDefaultIteration
    provides
    1
    for arbs with edgecases where
    minIterations > 1
    . Is this a bug or there's logic behind this? Right now
    computeDefaultIteration
    explicitly supports only
    Exhaustive
    https://github.com/kotest/kotest/blob/master/kotest-property/src/commonMain/kotlin/io/kotest/property/config.kt#L17
    s
    • 2
    • 39
  • k

    kopper

    12/22/2020, 8:47 AM
    Separate question - shouldn't
    minIterations
    for
    Arb
    include at least one sample? Right now it counts only all edge cases https://github.com/kotest/kotest/blob/master/kotest-property/src/commonMain/kotlin/io/kotest/property/Gen.kt#L39
    s
    • 2
    • 7
  • j

    Joel Hess

    12/31/2020, 7:41 PM
    If I spin up a Spec with the
    @SpringBootTest
    annotation, can I get access to the app context within a specific test? I’m trying to migrate some tests that look like this:
    contextRunner.run { context ->
       assertThat(context)
          .hasSingleBean(MongoCustomConversions::class.java)
    }
    and change properties on the context for a test?
    contextRunner
        .withPropertyValues("spring.data.mongodb.migrations.enabled:false")
        .run { context ->
            assertThat(context)
                .doesNotHaveBean(Mongobee::class.java)
        }
    s
    • 2
    • 10
  • s

    sam

    01/06/2021, 7:18 PM
    4.4.0.RC1 is being released. Would welcome any feedback and bug reports
    :awesome: 1
    k
    • 2
    • 86
  • n

    nelson ramirez

    01/08/2021, 3:12 AM
    Hi, Big fan of Kotest! Thanks for this amazing library. Newbie property testing question: I'm trying to compose an object with
    Arb.bind()
    , the object contains a list of other objects. I'm having trouble generating a list of objects to populate my main arb with.. Here's what I have
    class CartModelTest : StringSpec({
        "create Cart from CartEntity" {
            val cartItemArb: Arb<CartLineItemEntity> = Arb.bind(
                Arb.string(),
                <http://Arb.int|Arb.int>(1..999)
            ) { randomItemId, randomQuantity ->
                CartLineItemEntityBuilder()
                    .itemId(randomItemId)
                    .quantity(randomQuantity)
                    .build()
    
            }
            val cartEntityArb: Arb<CartEntity> = Arb.bind(
                Arb.string(),
                Arb.double(),
                <http://Arb.int|Arb.int>()
            ) { randomId, randomAmount, randomItemCount ->
                val amount = AmountBuilder().value(randomAmount).build()
                CartEntityBuilder()
                    .cartId(randomId)
                    .grandTotal(amount)
                    .subtotal(amount)
                    .totalDiscount(amount)
                    .numberOfItems(randomItemCount)
                        //TODO how do i create a random list of CartLineItems?
                    .itemList(listOf(cartItemArb.single()))
                    .build()
            }
            checkAll(cartEntityArb) { cartEntity ->
                val result = Cart.fromCartEntity(cartEntity)
                result.workfile shouldBe cartEntity.cartId
            }
        }
    })
    How do I populate itemList in my
    cartEntityArb
    with a list of
    cartItemArbs
    ?
    s
    • 2
    • 3
  • j

    Jim

    01/08/2021, 10:25 PM
    Should this work for overriding which tests are run by gradle when I run
    ./gradlew test
    ?
    test.doFirst {
        System.setProperty("kotest.tags", "Unit")
    }
    l
    • 2
    • 4
  • s

    Shalom Halbert

    01/11/2021, 9:53 PM
    Is there a way to run a single test from the command line if a test framework is used?
    s
    s
    +2
    • 5
    • 4
  • t

    taer

    01/12/2021, 3:02 PM
    Question on the output of test failures. The stack traces I get are pretty much useless sometimes. Is there something I'm doing incorrect? Will post in thread
    s
    • 2
    • 70
  • j

    Joel Hess

    01/13/2021, 9:37 PM
    I’m trying to convert some tests from straight jUnit and need a bit of help. I have this
    fun <T> assertValidation(o: Any, validation: Class<T>, propertyName: String? = null) {
    
            val violations = when (propertyName) {
                null -> validator.validate(o)
                else -> validator.validateProperty(o, propertyName)
            }
    
            assertAll(
                Executable {
                    assertEquals(
                        1,
                        violations.count(),
                        "Expecting one violation, received ${violations.count()}"
                    )
                },
                Executable {
                    violations.forEach { violation ->
                        val annotation = violation.constraintDescriptor.annotation
                        assertThat(annotation, instanceOf(validation))
                    }
                }
            )
    I’m trying to convert the type assertion to use ShouldBeInstanceOf<t> but the compiler doesn’t like it because its a generic type. I’m trying to change it to something along the lines of
    inline fun <reified T> assertValidation(o: Any, validation: Class<T>, propertyName: String? = null) {
            val violations = when (propertyName) {
                null -> validator.validate(o)
                else -> validator.validateProperty(o, propertyName)
            }
    
            assertSoftly {
                withClue("Expecting one violation, received ${violations.count()}") {
                    violations.shouldHaveSize(1)
                }
                violations.forEach { violation ->
                    val annotation = violation.constraintDescriptor.annotation
                    annotation.shouldBeInstanceOf<validation>()
                    //assertThat(annotation, instanceOf(validation))
                }
            }
        }
    How can I use ShouldBeInstanceOf in this case?
    s
    • 2
    • 7
  • k

    kopper

    01/18/2021, 12:41 AM
    Is the 4.4.0.RC1 expected to work with Kotest plugin? I am getting "Test framework quit unexpectedly" from IntelliJ. after the upgrade when I run the tests as Kotest (with the plugin).
    s
    • 2
    • 7
  • m

    Mikhail Galanin

    01/19/2021, 10:40 AM
    Hello! Can anyone give me a clue why 
    StringSpecScope
     doesn’t implement 
    ContainerScope
    ? It appeared that I can’t use
    io.kotest.core.datatest.forAll
    inside
    StringSpec
    (or I haven’t found a way…)
    s
    • 2
    • 16
  • h

    Hugo Martins

    01/20/2021, 6:56 PM
    Hello! I’m new here. Great work with
    kotest
    and thank you for all the work! I have a question, if anyone is available to answer it: I want to generate HTML reports from XML reports (built with Junit XML listener), with Gradle. I can’t seem to find a way to do it without any extra Gradle plugin. Is anyone aware of a listener (similar to what JUnit XML) that will allow me to run this after executing the entire
    kotest
    test suite? Thank you!
    👍🏻 1
    s
    • 2
    • 16
  • a

    Animesh Sahu

    01/21/2021, 5:18 AM
    Does assertion library support JS-IR?
    s
    • 2
    • 8
  • l

    Luis Daivid

    01/21/2021, 5:37 AM
    Can something like “Rule” be used in kotest? I need to set the MainCoroutineRule.
    s
    • 2
    • 21
  • l

    Luis Daivid

    01/24/2021, 11:01 AM
    Hi. I’m trying to use Kotest with Robolectric on android local test but I’m getting this error as soon as i run my test:
    java.lang.IllegalArgumentException: failed to configure io.kotest.extensions.robolectric.ContainedRobolectricRunner$PlaceholderTest.testPlaceholder: Package targetSdkVersion=30 > maxSdkVersion=29
    	at org.robolectric.RobolectricTestRunner.getChildren(RobolectricTestRunner.java:254)
    	at io.kotest.extensions.robolectric.ContainedRobolectricRunner.access$getChildren(ContainedRobolectricRunner.kt:7)
    	at io.kotest.extensions.robolectric.ContainedRobolectricRunner$placeHolderMethod$2.invoke(ContainedRobolectricRunner.kt:10)
    	at io.kotest.extensions.robolectric.ContainedRobolectricRunner$placeHolderMethod$2.invoke(ContainedRobolectricRunner.kt:7)
    	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
    	at io.kotest.extensions.robolectric.ContainedRobolectricRunner.getPlaceHolderMethod(ContainedRobolectricRunner.kt)
    	at io.kotest.extensions.robolectric.ContainedRobolectricRunner.access$getPlaceHolderMethod$p(ContainedRobolectricRunner.kt:7)
    	at io.kotest.extensions.robolectric.ContainedRobolectricRunner$sdkEnvironment$2.invoke(ContainedRobolectricRunner.kt:19)
    	at io.kotest.extensions.robolectric.ContainedRobolectricRunner$sdkEnvironment$2.invoke(ContainedRobolectricRunner.kt:7)
    	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
    	at io.kotest.extensions.robolectric.ContainedRobolectricRunner.getSdkEnvironment(ContainedRobolectricRunner.kt)
    	at io.kotest.extensions.robolectric.RobolectricExtension.instantiate(RobolectricExtension.kt:16)
    	at io.kotest.engine.InstantiateSpecKt.createAndInitializeSpec(instantiateSpec.kt:21)
    	at io.kotest.engine.spec.SpecExecutor.createInstance(SpecExecutor.kt:103)
    	at io.kotest.engine.spec.SpecExecutor.execute(SpecExecutor.kt:43)
    	at io.kotest.engine.KotestEngine$submitBatch$$inlined$forEach$lambda$1$1.invokeSuspend(KotestEngine.kt:139)
    	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    	at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:241)
    	at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:270)
    	at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:79)
    	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:54)
    	at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
    	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:36)
    	at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
    	at io.kotest.engine.KotestEngine$submitBatch$$inlined$forEach$lambda$1.run(KotestEngine.kt:138)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:748)
    test code is here:
    @RobolectricTest
    @Config(sdk = [Build.VERSION_CODES.P])
    class ExampleUnitTest: FunSpec ({
        test("test") {
            "aa" shouldBe "aa"
        }
    })
    How can i fix it?
    l
    • 2
    • 14
  • s

    Steffen Haase

    01/25/2021, 11:57 AM
    hi. I’ve got a weird mockk behaviour if I’m using
    relaxed=true
    . my env is kotlin, mockk and kotest .
    relaxed - allows creation with no specific behaviour
    in my case I expect an unspecified SimpleDataClass, something like
    SimpleDataClass(a = null)
    . In debug mode I can see that
    a = null
    but
    if( a != null)
    is true. I created a litte playground https://github.com/cryptoki/kotest-mockk-relaxed The picture shows the debugger output. Any ideas why the behaviour is like that? With
    relaxed=true
    there is a big space for mistakes if I’m bit lazy with my test. thanks.
    ↪️ 1
    s
    • 2
    • 3
  • m

    mboudraa

    01/28/2021, 4:25 PM
    HI, I’m trying to use kotest for the 1st time as it looks very promising. However, with the following test
    package com.bethesomm.firebase.auth
    
    import io.kotest.core.spec.style.FunSpec
    import io.kotest.matchers.ints.shouldBeExactly
    
    
    class FirebaseUserTest : FunSpec({
    
        test("should do whatever") {
            "hello".length shouldBeExactly 5
        }
    })
    I have the following error message
    [java.lang.ClassNotFoundException: com.bethesomm.firebase.auth.FirebaseUserTest]
    Did I miss something? FYI, I’m using the version 4.4.0.RC2
    s
    • 2
    • 23
  • m

    mboudraa

    01/28/2021, 4:33 PM
    Ok I made it work after restarting the IDE 😞 However, IO don’t know if that’s expected but when I run my tests through gradle, only the test written with kotest are recognized, all the other ones, written with Junit 5, are ignored. Is it an expected behavior?
    s
    m
    • 3
    • 6
  • m

    mboudraa

    01/28/2021, 4:59 PM
    All my issues above have been quickly fixed so I’m hoping for this last one to be as quick to solve 🙂 The last problem, I’m facing is whenever I change a test or add a test in Android Studio, the runner runs the test as if they didnt change. I have to rebuild the module everytime for the change to have an effect. Is there a specific configuration or a plugin besides the intelliJ one that I should add to make things work mor smoothly? FYI im on AS 4.2 beta3 and writing my tests in a multiplatform module
    s
    • 2
    • 17
  • i

    Imran/Malic

    01/29/2021, 4:56 PM
    Hi I wonder where it is possible to retrieve the Arb.seed for porperty-tests. I am in Kotest : 4.3.1. And depend on
    io.kotest:kotest-property
    . I have some Tests that fail every now and then and I wanted to save those edgecases, to ensure that their fixed
    s
    • 2
    • 16
Powered by Linen
Title
i

Imran/Malic

01/29/2021, 4:56 PM
Hi I wonder where it is possible to retrieve the Arb.seed for porperty-tests. I am in Kotest : 4.3.1. And depend on
io.kotest:kotest-property
. I have some Tests that fail every now and then and I wanted to save those edgecases, to ensure that their fixed
s

sam

01/29/2021, 5:03 PM
The seed is outputted to the console when an error fails, is that what you need?
i

Imran/Malic

01/29/2021, 7:33 PM
In most cases I get a report like this:
java.lang.AssertionError: Property failed after 1 attempts

Repeat this test by using seed 6157672104206447713
but in the application I am running the prop tests against I sometimes run into test error’s, where this is not supplied
s

sam

01/29/2021, 7:37 PM
Oh, what do you mean by test error ?
i

Imran/Malic

01/29/2021, 7:57 PM
A failed test, sorry if that was poorly expressed
s

sam

01/29/2021, 7:58 PM
So one with an exception other than assertion error, is what that you mean ?
like do you have a simple example
i

Imran/Malic

01/29/2021, 7:58 PM
yes correct
s

sam

01/29/2021, 7:58 PM
so
test("foo") {
  checkAll<String> { a -> error(boom") }
}
I can't duplicate it
test("errored test should print seed") {
   checkAll<Int, Int> { _, _ -> error("boom") }
}
i

Imran/Malic

01/29/2021, 8:03 PM
Yes, in my case its something like:
test("foo") {
  forAll(Arb.list(Arb.domainType) { records ->
saveElementsToDB(records)
  record == collectRecordsfromDB()
}
}
in some cases one or two elemts are missing
s

sam

01/29/2021, 8:03 PM
Property failed after 1 attempts
java.lang.AssertionError: Property failed after 1 attempts

Repeat this test by using seed -3454921614817430845
i

Imran/Malic

01/29/2021, 8:04 PM
Can I check in with you after this weekend if I can create a small reproducible example. Thanks for your help
s

sam

01/29/2021, 8:05 PM
yes of course, I will continue to have a play myself
i

Imran/Malic

01/29/2021, 8:05 PM
🙌🏽
Hi Sam, I was not able to reproduce it. Hopefully along the road I can come up with a small reproducible example. So far I’ve been just randomly testing seeds until one fails consistently 😅
View count: 4