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

    simon.vergauwen

    06/11/2020, 12:09 PM
    Sadly I don’t think something like
    MinSize
    is possible for
    Arb<List<A>>
    etc, which is also what I’m looking for in combination with
    minSuccessful
    . This way I could easily reduce the stress of the test suite depending on where it runs, or depending on what platform it runs when moving to MPP.
    s
    12 replies · 2 participants
  • f

    Friedger

    06/12/2020, 11:54 AM
    How would I use kotest in a multiplatform project? Any examples out there?
    s
    4 replies · 2 participants
  • g

    Gopal S Akshintala

    06/12/2020, 1:37 PM
    I have been getting this exception
    java.lang.NoSuchMethodError: 'double kotlin.time.Duration$Companion.getZERO-UwyO8pc()'
    when running any test with Kotest. I am on gradle 6.5, Kotlin - 1.4-M2, and using latest snapshots of Kotest. Can someone please help
    s
    6 replies · 2 participants
  • s

    savrov

    06/12/2020, 7:56 PM
    hello, is it possible to use kotest in kotlin mpp? And, if yes, could you provide some setup example/demo pls
    s
    1 reply · 2 participants
  • s

    sam

    06/14/2020, 4:50 PM
    Do you mean the play icon disappears. If so open bug for that
    s
    2 replies · 2 participants
  • g

    Grigory Derzhavets

    06/18/2020, 9:51 AM
    Hey I am using tags to filter out tests. I can not find a way how to solve a problem: when some tests are filtered out by tag, I need the runner not to run 
    beforeSpec/beforeTest
     methods. As I see right now, the test_executor firstly runs these and then filters out tests. Does anybody know whether it is possible in KotlinTest? Please
    s
    72 replies · 2 participants
  • n

    Neel Kamath

    06/19/2020, 3:35 AM
    I currently get extremely long lines when a
    dataClass1 shouldBe dataClass2
    test fails. Is there any way it could be pretty printed so that I needn't spend minutes manually formatting it every time to see the diff? I think I saw Gradle pretty print a
    List
    or something I had once. Sorry if this is unrelated to Kotest. I'm unsure whether this is issue is from Kotest, Gradle, JUnit, etc.
    l
    s
    4 replies · 3 participants
  • g

    Grigory Derzhavets

    06/19/2020, 8:12 AM
    Does new kotest plugin for IntelliJ support annotation spec? I moved the core to 4.1.0.RC2, it made me move from kotlintest to kotest plugin and the new plugin doesn't let me run (meaning there is no green arrow for the test method) my AnnotationSpec based tests. It allows to run StringSpec based tests though
    s
    19 replies · 2 participants
  • c

    christophsturm

    06/22/2020, 9:25 AM
    I’m having trouble running the js test example:
    ~/Projects/kotlin/kotest% ./gradlew kotest-examples:kotest-examples-javascript:jsTest
    
    > Configure project :
    Kotlin Multiplatform Projects are an experimental feature.
    
    The Kotlin source set commonTest was configured but not added to any Kotlin compilation. You can add a source set to a target's compilation by connecting it with the compilation's default source set using 'dependsOn'.
    See <https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#connecting-source-sets>
    
    > Task :kotest-examples:kotest-examples-javascript:installMocha
    npm WARN saveError ENOENT: no such file or directory, open '/Users/christoph/package.json'
    npm WARN enoent ENOENT: no such file or directory, open '/Users/christoph/package.json'
    npm WARN christoph No description
    npm WARN christoph No repository field.
    npm WARN christoph No README data
    npm WARN christoph No license field.
    
    + mocha@8.0.1
    updated 1 package and audited 191 packages in 1.527s
    found 0 vulnerabilities
    
    
    > Task :kotest-examples:kotest-examples-javascript:runMocha FAILED
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    A problem was found with the configuration of task ':kotest-examples:kotest-examples-javascript:runMocha' (type 'NodeTask').
    > File '/Users/christoph/Projects/kotlin/kotest/kotest-examples/kotest-examples-javascript/node_modules/mocha/bin/mocha' specified for property 'script' does not exist.
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Get more help at <https://help.gradle.org>
    
    Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
    Use '--warning-mode all' to show the individual deprecation warnings.
    See <https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings>
    
    BUILD FAILED in 3s
    14 actionable tasks: 2 executed, 12 up-to-date
    ~/Projects/kotlin/kotest%
    s
    2 replies · 2 participants
  • s

    sam

    06/23/2020, 5:54 PM
    Blog up: https://github.com/kotest/kotest/blob/master/blog/release_4.1.md
    🎉 4
    b
    s
    7 replies · 3 participants
  • s

    simon.vergauwen

    06/25/2020, 7:48 AM
    I’m seeing some weird behavior with plugin 1.0.2 and Kotest 4.1.0. Now it’s not picking up new tests, and when I rebuild I cannot run the suites (see attached log). Yesterday when I first upgraded I ran into the same, but without having it work first. But it strangely started working for me after a couple restarts/clearing caches. However it already re-appeared this morning.
    Untitled
    s
    w
    9 replies · 3 participants
  • m

    matthew graf

    06/26/2020, 8:44 PM
    Does anyone know of a clean way of doing assertions on the
    Either
    type (Arrow)? The
    shouldBeRight()
    matcher helps quite a bit but I found myself needing to use
    map
    to check values within that object
    val submittedPayment: Either<PaymentEventRepoError, Payment> = eventStore.getLatestPaymentForAccount(123)
              submittedPayment.map { it.amount }.shouldBeRight(50.00.toBigDecimal())
              submittedPayment.map { it.state }.shouldBeRight(PaymentState.PENDING)
    Its not so bad but I’m wondering if anyone has a better pattern
    s
    5 replies · 2 participants
  • x

    xenomachina

    06/26/2020, 9:38 PM
    Is there a simple way to run an individual Spec from IntelliJ? This works on a previous version of our code base that used kotlintest 3.4.2, but with kotest 4.1.0 the finest-grained thing I can run from IntelliJ seems to be the entire package which contains many specs. I tried installing the kotest plugin (1.0.2, which says it's for 4.1.0) and restarting IntelliJ, but I still get no "Run" options on individual specs.
    s
    j
    +1
    44 replies · 4 participants
  • j

    julian

    06/29/2020, 8:08 PM
    I'm testing the behavior of an asynchronous callback-based api. The callback can be called asynchronously by the api multiple times, each time with a result. I'd like to repeatedly check if each result fed to the callback is the expected value. But I'd like to stop doing this once a timeout has been reached. At that time I'd like to fail and exit the test. How may I achieve this in Kotest?
    s
    3 replies · 2 participants
  • a

    atara

    06/30/2020, 8:54 AM
    hi - does anyone know how to use virtual timer with kotest - in case I want to use the
    shouldThrow
    like this
    shouldThrow<Exception> {
                            client.callMyEndpoint(request).awaitSingle()
                        }
    s
    5 replies · 2 participants
  • s

    simon.vergauwen

    06/30/2020, 11:06 AM
    Arg 0: 0L (shrunk from 23)
    Arg 1: 1L (shrunk from 96)
    I’m seeing the above error message from the following
    Arb.long(20, 40), Arb.long(90, 100)
    . Is it expected that the values get shrunk outside of the allowed range?
    1 reply · 1 participant
  • b

    bbaldino

    06/30/2020, 9:29 PM
    Why get rid of the raw String methods (in `ShouldSpec`s case, at least) in favor of
    context
    ?
    s
    3 replies · 2 participants
  • b

    bbaldino

    06/30/2020, 10:41 PM
    Anyone seen
    Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test failed: java.lang.BootstrapMethodError: java.lang.IllegalAccessError: no such method: org.junit.platform.launcher.TagFilter.includeTags(List)PostDiscoveryFilter/invokeStatic: org/junit/platform/commons/PreconditionViolationException: org.junit.platform.commons.PreconditionViolationException -> [Help 1]
    before?
    s
    7 replies · 2 participants
  • b

    bbaldino

    07/02/2020, 4:25 PM
    I'm seeing an issue with the plugin where tests still show as in-progress even though they've all finished:
    s
    t
    43 replies · 3 participants
  • t

    tim

    07/03/2020, 1:41 PM
    Ahh ... it looks like when tests are excuted via gradle + cli my custom AbstractProjectConfig isn't being executed ... is that normal behaviour? I had to look at the stack trace to see that my tests were never running due to missing env variables which im currently setting in my PorjectConfig.
    s
    67 replies · 2 participants
  • j

    julian

    07/04/2020, 12:42 AM
    I notice that, when I'm using
    StringSpec
    and I have a particularly long test name, and split it up on separate lines, like this:
    "Given blah blah blah blah blah blah" + 
        " - When blah blah blah" + 
        " - Then blah blah blah" {
        TODO()
    }
    Then the test name in the Intellij run window will be truncated to just
    - Then blah blah blah
    . To remedy, I tried putting the concatenation in parens:
    ("Given blah blah blah blah blah blah" + 
        " - When blah blah blah" + 
        " - Then blah blah blah") {
        TODO()
    }
    This fixed the test name displayed in the run window. But the plugin no longer recognized the test, I think. Because it removed the single green arrow gutter icon from that test in IntelliJ. Is there a workaround that avoids both problems? Thanks!
    s
    13 replies · 2 participants
  • l

    LeoColman

    07/07/2020, 12:05 AM
    BeforeProject must be done at your
    ProjectConfig
    , keep that in mind 😉
    j
    3 replies · 2 participants
  • s

    simon.vergauwen

    07/07/2020, 9:59 AM
    I'm seeing in the Arrow Fx Coroutines test suite which uses Kotest 4.1.0, whenever a test times out. I see it with an error java.lang.InterruptedException, and all following tests in the suite fail with Timeout (which makes the suites take forever on CI too).
    Stacktrace
    s
    27 replies · 2 participants
  • p

    peekandpoke

    07/08/2020, 12:03 PM
    Hi! Can I find an example of how to test multi-platform code? I have a jvm/js library and most of the code is in commonMain. How do I write tests in commonTest or better: which depedencies do I need to pull. And then what is the gradle task to run the tests?
    s
    4 replies · 2 participants
  • c

    Cameron Lane

    07/08/2020, 1:13 PM
    Could someone tell me which maven repository kotest-runner-console-jvm lives in? I wasnt able to find it in maven central
    s
    2 replies · 2 participants
  • s

    sam

    07/08/2020, 2:09 PM
    The test and its children
    👍 1
    s
    17 replies · 2 participants
  • d

    David Glasser

    07/08/2020, 5:06 PM
    We have some legacy tests written in JUnit alongside kotest tests. I can use kotest matchers in JUnit tests, right? It looks like all that matchers do is construct some `MatcherResult`s and then
    should
    uses
    ErrorCollector
    (a singleton object) to by-default throw?
    s
    l
    3 replies · 3 participants
  • b

    bbaldino

    07/09/2020, 7:53 PM
    I have some ktor server tests and ktor's server test harness involves executing the requests inside of a scope, which means my verification of the responses happens there. Looks something like this:
    context("when the server") {
        withTestApplication({
            myServerModule()
        }) {
            context("receives a request for url/to/something") {
                with(handleRequest(<http://HttpMethod.Post|HttpMethod.Post>, "url/to/som ething") {
                    should("return the correct response") {
                        response.status() shouldBe HttpStatusCode.OK
                    }
                }
            }
        }
    }
    This doesn't work though, as where
    should
    is there isn't a coroutine scope and it complains. Is there a better way to do tests like this? Or would it be possible to have a non-suspend version of
    should
    ?
    s
    l
    57 replies · 3 participants
  • m

    mattmoore

    07/10/2020, 3:55 AM
    Specifically, I care about
    freeCompilerArgs
    r
    7 replies · 2 participants
  • s

    Skolson5903

    07/11/2020, 7:38 PM
    I'm having trouble using Kotest with a multi-platform project. Using the new 1.4-M3 project wizard, I started a new MpTest project with IOS and Android as targets. The wizard generates a number of modules, the one I'm focusing on for this issue is the "shared" module. "Shared" gets 6 source directories built by the M3 wizard; androidMain, androidTest, commonMain, commonTest, iosMain, and iosTest. For this issue I'm using commonMain for a couple of multi-platform classes, and androidTest for Kotest 4.1.1 unit tests of the commonMain classes. The trouble occurs when using the plugin to attempt to debug the unit test class (in this case "BasicsTest"):
    Exception in thread "main" java.lang.ClassNotFoundException: BasicsTest
    Looking at the invoked gradle build I can see no evidence that it attempted to build the unit test class BasicsTest, so it's not on the classpath. If I then try to edit the Run Configuration for the debug attempt, it shows the plugin selected the "shared" classpath by default. Dropping down the list of classpaths available does not show shared.androidTest as a choice. So I have no way to invoke a debug of a unit test on a multi platform project's shared module. Is this a Kotest plugin issue? Or a multiplatform M3 issue? Until I resolve this I don't see a way to debug/run Kotest unit tests that are using common classes in the IDE. Thanks in advance for any info/help. FWIW I have already posted a precursor question of this problem as a recent thread in #eap, in that thread we concluded it better to post here: https://kotlinlang.slack.com/archives/C0KLZSCHF/p1594327039086400
    s
    2 replies · 2 participants
Powered by Linen
Title
s

Skolson5903

07/11/2020, 7:38 PM
I'm having trouble using Kotest with a multi-platform project. Using the new 1.4-M3 project wizard, I started a new MpTest project with IOS and Android as targets. The wizard generates a number of modules, the one I'm focusing on for this issue is the "shared" module. "Shared" gets 6 source directories built by the M3 wizard; androidMain, androidTest, commonMain, commonTest, iosMain, and iosTest. For this issue I'm using commonMain for a couple of multi-platform classes, and androidTest for Kotest 4.1.1 unit tests of the commonMain classes. The trouble occurs when using the plugin to attempt to debug the unit test class (in this case "BasicsTest"):
Exception in thread "main" java.lang.ClassNotFoundException: BasicsTest
Looking at the invoked gradle build I can see no evidence that it attempted to build the unit test class BasicsTest, so it's not on the classpath. If I then try to edit the Run Configuration for the debug attempt, it shows the plugin selected the "shared" classpath by default. Dropping down the list of classpaths available does not show shared.androidTest as a choice. So I have no way to invoke a debug of a unit test on a multi platform project's shared module. Is this a Kotest plugin issue? Or a multiplatform M3 issue? Until I resolve this I don't see a way to debug/run Kotest unit tests that are using common classes in the IDE. Thanks in advance for any info/help. FWIW I have already posted a precursor question of this problem as a recent thread in #eap, in that thread we concluded it better to post here: https://kotlinlang.slack.com/archives/C0KLZSCHF/p1594327039086400
Whatever this is, it isn't just Kotest. In the same project setup, I wrote a basic test class in commonTest using kotlin.test package stuff available for multi-platform, and it gets the same error. It acts similar in Idea as this old thread: StackOverflow old issue So I'm gonna start digging into what's going on with gradle in this config. Since now this issue only involves 1.4-M3 and multi platform, would this post be better off in the #multiplatform channel until I can find the root cause? Or is it still helpful to Kotest?
s

sam

07/14/2020, 4:39 AM
Yes I think it would be useful to keep us aprised
View count: 5