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

    sam

    02/17/2020, 11:54 AM
    Take a look at withClue and asClue
    👍 2
    c
    • 2
    • 2
  • s

    Sourabh Rawat

    02/20/2020, 6:41 AM
    can some fix this in high priority? https://github.com/kotest/kotest/issues/1223
    l
    s
    • 3
    • 7
  • d

    Dias

    02/20/2020, 11:06 AM
    as in the rest why asserAll/forAll are not suspend functions?
    w
    s
    +2
    • 5
    • 29
  • a

    Angelina

    02/22/2020, 10:20 PM
    👋 hello! I have an issue with beta1 kotest version in :android: . if i run
    gradlew test
    it freezes 🙄 anyone else experienced this issue? I have default config (1 thread). I tried to add custom config but kotest did not pick it up 🤷‍♀️
    l
    s
    +2
    • 5
    • 51
  • e

    elect

    03/03/2020, 9:11 AM
    hi, is it possible to pass some arguments to the tests?
    f
    m
    s
    • 4
    • 11
  • a

    Ahmed Ibrahim

    03/04/2020, 3:24 PM
    Is anyone getting
    java.lang.NoClassDefFoundError: kotlin/time/MonoClock
    when running kotest with Kotlin 1.3.70?
    i
    s
    • 3
    • 5
  • a

    akowal

    03/09/2020, 2:51 PM
    Hey guys! I just started with kotest + mockk and instantly faced an issue: since all tests are declared within one big lambda passed to ctor (
    StringSpec
    ), all the mocks I need are declared as local variables inside same lambda and not re-initialized for each test case (like in vanilla JUnit). Essentially it means that the 2nd test can see mock invocations from the 1st one, messing up all verifications. How can I avoid that?
    l
    w
    • 3
    • 5
  • w

    wasyl

    03/09/2020, 3:17 PM
    Actually I’m curious, what’s the use case for
    InstancePerTest
    isolation mode? The way we’re using kotest right now is with
    DescribeSpec
    , so we have bunch of
    describe
    and
    context
    blocks which set up tests for the
    it
    blocks which contain the assertions. Iiuc,
    InstancePerLeaf
    will create new instance of the test for each
    it
    block, and execute everything that leads to it.
    InstancePerTest
    would create new instance not only for
    it
    block, but also for
    describe
    and
    context
    , is that correct?
    s
    • 2
    • 2
  • a

    akowal

    03/09/2020, 3:27 PM
    Btw, how can I change isolation mode for a single spec, not for a whole project?
    l
    • 2
    • 3
  • a

    Ashish Kumar Joy

    03/10/2020, 10:20 AM
    @akowal @Tesserakt Kotest Assertions are now available as separate module you can add them in your build file as. “io.kotest:kotest-assertions-core:4.0.0-BETA2” Separating the assertion module help users to use kotest framework independent of assertions
    t
    a
    +2
    • 5
    • 7
  • c

    Cody Engel

    03/14/2020, 6:25 PM
    Hey everyone, I’m trying to run a sample test with kotest but it never gets past the
    Extensions
    step, when I stop the execution it ends saying
    Test events were not received
    . This is the sample test I’m trying to run…
    class SimpleTest : FunSpec({
        test("just a simple test") {
            1 + 1 shouldBe 2
        }
    })
    s
    l
    • 3
    • 6
  • t

    thanksforallthefish

    03/16/2020, 7:32 AM
    is it expected that
    class SampleTest : ExpectSpec() {
      init {
        context("test") {
          expect("sum") {
            1 + 1 shouldBe 3
          }
          expect("sum right") {
            1 + 1 shouldBe 2
          }
        }
      }
    }
    expect("sum right')
    is ignored? I am trying to better understand isolation modes, tests and leaves and was a bit surprised by this case, also because changing isolation mode does not affect the result. kotest 3.4.2
    w
    • 2
    • 2
  • a

    Ashish Kumar Joy

    03/17/2020, 8:46 AM
    In addition to kotest-runner-junit5 you will need the assertion module as well, please have look at https://github.com/kotest/kotest/blob/master/README.md
    h
    • 2
    • 3
  • s

    Steve RB

    03/21/2020, 10:37 AM
    Hey folks, I've just started using kotest and had a question: • Has anyone been able to get the "<Click to see difference>" dialog with diff window to appear when an assertion fails using intellij? This diff window is super helpful when doing a "foo" shouldBe "bar". This seems to work with the core kotlin.test assertEquals method but the shouldBe, etc all seem to throw a too generic AssertionError which intellij doesn't seem to be able to understand. Any help would be much appreciated
    s
    • 2
    • 8
  • a

    Angelina

    03/26/2020, 11:34 AM
    tasks.withType<Test> {
        useJUnitPlatform()
    }
    In multimodule app this code ⬆️ should be in each module or can be in Project level build gradle file?
    s
    • 2
    • 4
  • a

    Angelina

    03/26/2020, 11:50 AM
    minor typo:
    object ProjectConfig : AbstractProjectConfig {
    object ProjectConfig : AbstractProjectConfig() {
    https://github.com/kotest/kotest/blob/master/doc/project_config.md
    s
    • 2
    • 3
  • l

    LeoColman

    03/26/2020, 4:48 PM
    What gradle version are you using?
    t
    s
    • 3
    • 38
  • s

    Steve RB

    03/27/2020, 9:48 AM
    Now that version 4 has been released - in there any scope to update the intellij kotlin-test plugin to support this version @sam? https://plugins.jetbrains.com/plugin/11585-kotlintest
    s
    • 2
    • 3
  • t

    T C

    03/27/2020, 10:39 AM
    Hey, checking out kotest for the first time. Using Android Studio with gradle version 5.6.4, gradle plugin version 3.6.1. In build.gradle (:app) I have
    dependencies {
        ...
        testImplementation 'io.kotest:kotest-runner-junit5:4.0.1'
        testImplementation 'io.kotest:kotest-assertions-core-jvm:4.0.1'
        testImplementation "io.mockk:mockk:1.9.3"
        testImplementation 'junit:junit:4.12'
    }
    as well as
    android.testOptions {
        unitTests.all {
            useJUnitPlatform()
        }
    }
    when trying to mimic examples from the docs I cannot seem to be able to extend any of the Spec classes (just getting unresolved reference) nor use keywords like
    shouldBe
    . The only package I seem to be able to `import`is
    io.kotest.matchers
    . Any idea what I am missing? Thanks!
    t
    • 2
    • 2
  • s

    sam

    03/27/2020, 1:03 PM
    Arch test is junit 4?
    a
    m
    • 3
    • 9
  • c

    Christian Nedregaard

    03/29/2020, 11:14 AM
    Thanks @sam and @LeoColman A couple of follow up questions: 1: If i add a
    afterTest {
            println("afterTest called for '${it.a.name}'")
        }
    ..i get
    beforeTest called for 'when container when' of type: Container
    afterTest called for 'when container when'
    beforeTest called for 'should container should' of type: Container
    
    beforeTest called for 'the tests' of type: Test
    testing
    afterTest called for 'the tests'
    
    afterTest called for 'should container should'
    So it seems like the
    When
    is completed before (or independently of) its children while the
    should
    is completing its children before completing itself. Is this an explicit approach or should I just not make to many assumptions regarding the ordering of completions? 2: Do you have a recommended approach for doing setup/teardown scoped on
    When
    for resources that are to be available for all the Whens children? Not for every
    When
    in the spec but for a single instance. I'm moving over from Spek 1 where this could be achieved with `beforeGroup`/`afterGroup`. The only approach I have found so far is to factor these cases out into separate specs. Leaf isolation mode would not be optimal since it would recreate the resource for each TEST not for each When. I suspect I need to adjust my expectation as to the contract Kotest offers reg. the relationship between nested containers/tests.
    s
    • 2
    • 4
  • j

    julian

    03/31/2020, 10:52 PM
    How was this issue resolved? https://github.com/kotest/kotest-intellij-plugin/issues/17 Reason I ask is I'm getting a similar error:
    Exception in thread "main" java.lang.NoClassDefFoundError: io/kotlintest/runner/jvm/TestEngineListener
    s
    • 2
    • 3
  • t

    Trejon House

    03/31/2020, 10:57 PM
    Hopefully a quick question. I'm using Kotest to run my android instrumented tests, and I am currently using
    androidTestImplementation('io.kotest:kotest-runner-junit5-jvm:4.1.0.197-SNAPSHOT')
    in my build.gradle, but Android Studio is giving me the following error:
    org.junit.runners.model.InvalidTestClassError: Invalid test class 'com.bytonomy.tech.nyteout.architecture.test.utilities.ApplicationSettingsSpec':
    1. No runnable methods
    at org.junit.runners.ParentRunner.validate(ParentRunner.java:525)
    at org.junit.runners.ParentRunner.<init>(ParentRunner.java:92)
    at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:74)
    Is this a known issue with this version?
    s
    l
    • 3
    • 3
  • t

    taer

    04/02/2020, 8:34 PM
    quick upgrade question. Where did List.shouldContainAll() run off to?
    a
    • 2
    • 1
  • s

    sam

    04/02/2020, 10:34 PM
    That was quick
    l
    t
    • 3
    • 3
  • w

    wasyl

    04/03/2020, 4:06 PM
    Hey guys 🙂 In JUnit running stuff in a test scope is pretty straightforward:
    @Test fun someTest = testScope.runBlockingTest { }
    . Is there some well-established pattern for running specs in a test scope? For example, do you wrap topmost test block, or maybe each smaller scope separately? Would it make sense if Kotest facilitated (or maybe it does?) running tests with coroutines in a test scope, by allowing injecting it or providing. I don’t think there’s any configuration regarding that though, is there?
    s
    • 2
    • 11
  • s

    sam

    04/04/2020, 12:20 AM
    4.0.2 has been released
    🎉 2
    s
    t
    • 3
    • 5
  • s

    SerVB

    04/07/2020, 12:37 PM
    Haven't anyone created a ticket at https://youtrack.jetbrains.com/issues/KT to allow to extract lambda outside the constructor parameters? It will be great to have such a feature for kotest: instead of
    class MyTest : FreeSpec({
        // ...
    })
    it will be possible to write like
    class MyTest : FreeSpec {
        // ...
    }
    m
    s
    • 3
    • 9
  • a

    Attila Domokos

    04/07/2020, 8:23 PM
    Hello! 👋 I am trying to switch our medium-sized Kotlin project from using
    kotlintest
    to
    kotest
    . However, we have a grpc project, where Kotest is having some issues. Has anybody seen this? Would you have suggestions on how to fix it?
    * What went wrong:
    Execution failed for task ':integration-grpc-server:extractIncludeTestProto'.
    > Could not resolve all files for configuration ':integration-grpc-server:testCompileProtoPath'.
       > Could not resolve io.kotest:kotest-runner-junit5-jvm:4.0.2.
         Required by:
             project :integration-grpc-server
          > Cannot choose between the following variants of io.kotest:kotest-runner-junit5-jvm:4.0.2:
              - jvm-api
              - jvm-runtime
              - metadata-api
            All of them match the consumer attributes:
              - Variant 'jvm-api' capability io.kotest:kotest-runner-junit5-jvm:4.0.2:
                  - Unmatched attributes:
                      - Found org.gradle.status 'release' but wasn't required.
                      - Found org.gradle.usage 'java-api' but wasn't required.
                      - Found org.jetbrains.kotlin.platform.type 'jvm' but wasn't required.
                  - Compatible attribute:
                      - Required org.gradle.libraryelements 'resources' and found compatible value 'jar'.
              - Variant 'jvm-runtime' capability io.kotest:kotest-runner-junit5-jvm:4.0.2:
                  - Unmatched attributes:
                      - Found org.gradle.status 'release' but wasn't required.
                      - Found org.gradle.usage 'java-runtime' but wasn't required.
                      - Found org.jetbrains.kotlin.platform.type 'jvm' but wasn't required.
                  - Compatible attribute:
                      - Required org.gradle.libraryelements 'resources' and found compatible value 'jar'.
              - Variant 'metadata-api' capability io.kotest:kotest-runner-junit5-jvm:4.0.2:
                  - Unmatched attributes:
                      - Required org.gradle.libraryelements 'resources' but no value provided.
                      - Found org.gradle.status 'release' but wasn't required.
                      - Found org.gradle.usage 'kotlin-api' but wasn't required.
                      - Found org.jetbrains.kotlin.platform.type 'common' but wasn't required.
    Jvm version:
    Using java version 13.0.2.hs-adpt
    This worked fine with the latest version of
    kotlintest
    .
    l
    s
    • 3
    • 13
  • a

    Attila Domokos

    04/08/2020, 2:53 PM
    Another thing I bumped into while switching to
    kotest
    is using
    shouldThrow
    in our tests. We are getting an error with the message:
    Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
    . I got around to it by specifying the highest jvm version we could go with in `build.gradle.kts`:
    tasks.withType<KotlinCompile> {
        kotlinOptions.jvmTarget = "12"
    }
    However, I did not have to specify this in
    kotlintest
    and I wish we could keep it that way. What is the root cause of seeing this error? How
    kotest
    changed that triggered it? - This is for my own educational purpose. Also (this might be a #gradle question), is it possible to specify this constraint for tests only in gradle?
    • 1
    • 1
Powered by Linen
Title
a

Attila Domokos

04/08/2020, 2:53 PM
Another thing I bumped into while switching to
kotest
is using
shouldThrow
in our tests. We are getting an error with the message:
Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
. I got around to it by specifying the highest jvm version we could go with in `build.gradle.kts`:
tasks.withType<KotlinCompile> {
    kotlinOptions.jvmTarget = "12"
}
However, I did not have to specify this in
kotlintest
and I wish we could keep it that way. What is the root cause of seeing this error? How
kotest
changed that triggered it? - This is for my own educational purpose. Also (this might be a #gradle question), is it possible to specify this constraint for tests only in gradle?
This seems to be working, I wonder if this is correct:
tasks {
     withType<Test> {
         withType<KotlinCompile> {
             kotlinOptions.jvmTarget = "12"
         }
     }
}
View count: 16