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
kotlintest
  • t

    thanh

    09/29/2019, 2:06 PM
    hello, how can I add kotlintest snapshot version as my dependency? I don't see how to do that in github page.
    l
    • 2
    • 6
  • e

    EarthCitizen

    10/06/2019, 4:46 PM
    @Vinicius Araujo It would also be helpful to understand what you are trying to do.
    v
    • 2
    • 2
  • l

    LeoColman

    10/09/2019, 8:48 PM
    Ah, I see. It's not a rest request to anywhere or anything like that?
    l
    • 2
    • 1
  • h

    Hexa

    10/19/2019, 10:56 AM
    when should one use shouldspec vs behaviourspec vs stringspec when unit testing? there’s so many different types its quite confusing
    w
    m
    s
    • 4
    • 4
  • z

    zceejkr

    10/19/2019, 12:03 PM
    Hello, one question: is the kotlintest library multiplatform compatible?
    l
    s
    • 3
    • 4
  • w

    wasyl

    10/20/2019, 11:28 AM
    Hi 🙂 I’m curious about the Arrow dependency that’s pulled in with KotlinTest — did you have a discussion somewhere about it being not part of the public API? For example having Arrow matchers in a separate artifact, and if KotlinTest uses Arrow internally then not exposing it? I’m not using Arrow but with KotlinTest I get tons of extension functions from it on most of the classes. Should I just e.g. exclude Arrow transitive dependency if I’m not gonna use those matchers? I only recall there was some discussion about splitting core and matchers into multiple artifacts but afaik the result was that there will be only one artifact. Maybe it’s something that could be reconsidered for the next major version?
    l
    s
    • 3
    • 36
  • l

    LeoColman

    11/02/2019, 7:59 PM
    Yeah, I'll give it a try anyways 👌
    Feel free to ask us if you have any doubts 🙂
    r
    s
    • 3
    • 24
  • w

    wasyl

    11/07/2019, 12:06 PM
    I’d like to vote for this feature, it’s I think the only that’s missing from classic bdd testing frameworks. Right now it’s a bit awkward to set isolation mode to per-test, and still have to write cleanup code after the last test. The advantage of current approach is we don’t need
    lateinit
    keyword, while setting stuff from closures will often make it necessary
    👍🏾 1
    j
    s
    • 3
    • 21
  • s

    Sergio Crespo Toubes

    11/08/2019, 8:58 AM
    Why this tests sometimes is success and sometimes failed?
    fun loadData = MainScope().launch {
        view.showProgressDialog()
        // load data
    }
    
    Given(""){
        When(""){
            runBlocking {
                withContext(Dispatchers.Main) {
                    presenter.loadData()
                }
            }
    
            Then("show progress dialog") {
                verify(exactly = 1) {
                    view.showProgressDialog() 
                }
            }
        }
    }
    I am loading coroutines with this way
    val mainThreadSurrogate = newSingleThreadContext("Main thread")
    override fun isolationMode(): IsolationMode = IsolationMode.InstancePerLeaf
    
    override fun beforeSpec(spec: Spec) {
        super.beforeSpec(spec)
        Dispatchers.setMain(mainThreadSurrogate)
    }
    
    override fun afterSpec(spec: Spec) {
        super.afterSpec(spec)
        mainThreadSurrogate.close()
    }
    w
    l
    s
    • 4
    • 18
  • a

    acando86

    11/09/2019, 12:30 PM
    i might have missed some announcement in this chat previously , apologies if this is the case, but is there any news about the gradle plugin which avoids the JUnit platform for kotlintest? Sam mentioned he was working on it some time ago, but i'm not sure what's the status of it currently.. Especially to handle nesting of tests
    s
    • 2
    • 1
  • s

    savrov

    11/09/2019, 4:40 PM
    Hello,I followed this tutorial (https://www.zuhaibahmad.com/android-spec-testing/) but my output looks different than from the article. Mine looks like in attached pic - prints only “then” steps. But I wanna see all steps printed out. Can you suggest me a solution, please?
    l
    • 2
    • 6
  • j

    julian

    11/09/2019, 11:43 PM
    How come all the for-alls in
    io.kotlintest.data
    are
    forall
    instead of
    forAll
    like the capitalization pattern applied in the rest of the library? It took 5 minutes for me to realize that the compiler was giving problems because I was using, and importing, the wrong for-all.
    l
    s
    • 3
    • 12
  • s

    sam

    11/12/2019, 11:28 PM
    Yep, ignores whitespace, etc. So
    """ { "name" : "sam" }""".shouldMatchJson("      {            "name": \n\n: "sam" \n\n }"""
    😍 2
    v
    • 2
    • 18
  • b

    BorzdeG

    11/14/2019, 6:48 PM
    Tell me how to use
    forall
    with suspend functions?
    s
    w
    • 3
    • 5
  • w

    wasyl

    11/14/2019, 7:06 PM
    Any idea how to debug failing test if all I see in console is
    com.example.TestClass > com.example.TestClass > executionError FAILED
        org.mockito.exceptions.base.MockitoException at TestClass.kt:168
    null
    java.lang.NullPointerException
            at org.gradle.api.internal.tasks.testing.results.StateTrackingTestResultProcessor.started(StateTrackingTestResultProcessor.java:45)
            at org.gradle.api.internal.tasks.testing.results.AttachParentTestResultProcessor.started(AttachParentTestResultProcessor.java:38)
    followed by a bunch of
    Received a failure event for test with unknown id '4.74'. Registered test ids: '[4.70, 4.64, 4.1, :data:graphql-networking:test]'
    java.lang.IllegalArgumentException: Received a failure event for test with unknown id '4.74'. Registered test ids: '[4.70, 4.64, 4.1, :data:graphql-networking:test]'
            at org.gradle.api.internal.tasks.testing.results.StateTrackingTestResultProcessor.failure(StateTrackingTestResultProcessor.java:103)
            at org.gradle.api.internal.tasks.testing.results.AttachParentTestResultProcessor.failure(AttachParentTestResultProcessor.java:43)
    ?
    s
    • 2
    • 6
  • i

    Ian Thomas

    11/15/2019, 11:03 AM
    Hi everyone, I’m currently learning kotlintest by adding it to a spring boot project (which uses spring data jpa). A quick question around working with test data, I can load data into h2 as expected by including a
    data.sql
    file in my test resources folder, but I’d prefer to have fixtures per test, ideally using the
    @Sql
    annotation. However, this annotation doesn’t seem to be usable with the kotlintest spec style and applying it to a
    beforeTest
    method also doesn’t seem to work. Has anyone got any experience working with this sort of thing or any tips for a better way to work with test data? Thanks!
    m
    s
    l
    • 4
    • 6
  • b

    bbaldino

    11/16/2019, 12:15 AM
    could you guys clarify the rerlationship between kotlintest and junit 5? is it that kotlintest is "built on top" of junit5, in a way? i'm trying to have an explanation ready for why i need to bring maven-surefire-plugin into an existing java project as we start adding kotlin/kotlintest
    m
    s
    +2
    • 5
    • 7
  • b

    bbaldino

    11/18/2019, 6:59 PM
    noticing some weird scoping of results: the following test class:``` class ScopeTest : ShouldSpec() { override fun isolationMode(): IsolationMode? = IsolationMode.InstancePerLeaf init { "scope1" { "scope2" { should("scope3") { } should("scope4") { } } } } ```
    s
    • 2
    • 9
  • d

    dr.dreigh

    11/20/2019, 9:54 AM
    Hi, when using the generators for Property based testing, is there a way to genereate nulls for nullable types? e.g. we are calling
    Gen.string()
    I'm looking for something like
    Gen.string().withNulls()
    or similar
    l
    • 2
    • 4
  • t

    Thomás Horta

    11/26/2019, 4:05 AM
    Hey everyone, just started learning about KotlinTest and tried using it on a small personal project, but as soon as I configured my CI on Bitrise and it ran my tests (which are written using BehaviorSpec) I noticed that the JUnit / Gradle test report outputs only the Then sentence as the test name (without the Given / When hierarchy to give context) which makes the Spec pretty much unusable for meaningful reports. Anyone facing this and found a workaround? (I found this StackOverFlow question, but no responses so far: https://stackoverflow.com/questions/56899882/kotlintest-junit-reports-arent-containing-the-behaviorspec-steps).
    p
    s
    • 3
    • 3
  • l

    LeoColman

    11/26/2019, 5:08 PM
    But something like
    Gen.lines(file).take(1000)
    would be very easy to use (and to implement)
    m
    s
    i
    • 4
    • 5
  • t

    Terje Andersen

    11/27/2019, 7:54 AM
    👋 I have a small issue with running tests in Intellij IDEA; that when I double-click / mark and hit enter on a stringspec test in Intellij IDEA test results, the IDE does not lead me to the test code, instead, nothing happens. Has anyone experienced the same? A bit about the project if relevant: It's a Spring Boot 2.1.10 project with maven-surefire-plugin 3.0.0-M1, junit5 and kotlintest (tests are written in both junit5 and kotlintest). We also use testcontainers that have a dependency on junit4.
    m
    l
    • 3
    • 5
  • h

    Hexa

    11/28/2019, 8:14 PM
    Anyone got example kotlintest being use in a ktor project?
    a
    • 2
    • 2
  • h

    henrik

    12/02/2019, 12:25 PM
    Any idea why IntelliJ IDEA (2019.3) doesn't show
    Run MyTest
    for kotlintests in buildSrc? It works in the regular source tree, and the tests are run if I run
    gradle test
    on the command line.
    s
    • 2
    • 5
  • b

    bbaldino

    12/02/2019, 9:12 PM
    is it frowned upon to add custom test context to a, say,
    AbstractShouldSpec.ShouldScope
    in order to make tests a bit cleaner? or is that the idea?
    s
    l
    • 3
    • 24
  • s

    sam

    12/08/2019, 2:35 AM
    We want to do
    a shouldMatchJson "foo"
    p
    • 2
    • 6
  • a

    Animesh Sahu

    12/08/2019, 2:38 PM
    How to attach listener/override listeners inside lambda based spec? https://github.com/kotlintest/kotlintest/blob/master/doc/reference.md#listeners usecase:
    class MyTest: StringSpec({
        val destroyable = Destroyable()
    
        // attach afterSpec listener
        // override fun afterSpec() = destroyable.destroy()
    })
    l
    • 2
    • 4
  • q

    Quinn

    12/11/2019, 5:02 PM
    Anybody have any good examples of using the StringSpec with listeners? First dip into kotlin in a while and I'm trying to start with unit testing.
    m
    l
    • 3
    • 23
  • l

    Luke Rohde

    12/17/2019, 10:27 PM
    is there a trick to getting jacoco to recognize kotlintest tests?
    l
    • 2
    • 18
  • s

    sam

    01/03/2020, 7:53 AM
    There's a ticket to fix that
    v
    • 2
    • 8
Powered by Linen
Title
s

sam

01/03/2020, 7:53 AM
There's a ticket to fix that
v

Vitali Plagov

01/03/2020, 7:55 AM
Have you seen this issue on GitHub Issues or in YouTrack?
s

sam

01/03/2020, 9:18 AM
Github
v

Vitali Plagov

01/03/2020, 11:28 AM
Was searching for it by
reflect
&
reflection
keywords but didn’t find anything…
Ok, maybe it will be mentioned in release notes for next releases
s

sam

01/03/2020, 11:30 AM
Good idea
Related but not the exact issue https://github.com/kotlintest/kotlintest/issues/1140
v

Vitali Plagov

01/03/2020, 12:58 PM
Yes, saw it too. Thanks for sharing
s

sam

01/03/2020, 12:58 PM
Welcome thanks for the feedback
View count: 5