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
test
  • i

    igor.wojda

    08/01/2017, 12:10 PM
    I wasn't aware that #spek exists. Thanks I'll eask there BTW @adambl4 do you have sample of working project?
    a
    • 2
    • 4
  • n

    natpryce

    08/10/2017, 2:32 PM
    Hi. I’ve published v 3.5.0.0 of snodge, a mutation-based fuzzer that can fuzz JSON, XML, HTML forms, text and binary data. It’s available in Maven Central for the JVM platform, and in NPM for JavaScript (as the package
    snodge-3
    version 5.0.0) https://github.com/npryce/snodge
    p
    a
    • 3
    • 7
  • j

    jackmiras

    08/11/2017, 3:34 PM
    @jk do you know what is the difference between
    memoized
    and the standard delegates from Kotlin?
    j
    • 2
    • 1
  • p

    pkazm

    08/30/2017, 10:26 AM
    Hi, I’m writing unit tests for a kotlin-only module in my android project, and when I try to run tests I get message
    Class not found: <test class path> Empty test suite.
    JRE is configured to be 1.8 (which is default for my module), also JUnit 4.12. Do you have any suggestions to what I could’ve missed?
    e
    p
    • 3
    • 3
  • k

    khanhbkqt

    10/16/2017, 9:23 AM
    Hi there! Anyone has tried Kotlin with mockito? I called verify method on a mocked object. But it invokes the implementation then I got error. Any suggestion? Thank you
    d
    • 2
    • 2
  • t

    tianhao

    10/16/2017, 12:28 PM
    Any Kotlin specific testing frameworks are recommended or Junit? Thanks.
    j
    • 2
    • 1
  • r

    roberto.guerra

    10/16/2017, 4:15 PM
    @khanhbkqt any examples and error messages?
    k
    • 2
    • 1
  • a

    artem_zin

    10/19/2017, 11:57 AM
    @khanhbkqt easiest solution would be to use
    mockito-kotlin
    https://github.com/nhaarman/mockito-kotlin/blob/916f186df947d3b69b14b1f5dc286555dc625549/mockito-kotlin/src/main/kotlin/com/nhaarman/mockito_kotlin/ArgumentCaptor.kt#L32
    k
    a
    • 3
    • 4
  • y

    yousuf.haque

    01/22/2018, 5:47 PM
    @agrosner I believe jacoco has a hard time parsing classes that have more than 1 dollar sign in the class name, and lambas are represented with dollar signs
    a
    • 2
    • 1
  • p

    patjackson52

    01/29/2018, 2:27 AM
    @rkeazor Spek’s stye of testing is really descriptive and it has a great api. Closely matches BDD test style in other languages, which can be a plus if your familiar with those, or if your porting a project from one of those languages and it has good test coverage. Overall I’m very pleased with it, but has some rough edges - tooling and reporting are not as well supported as the Junit ecosystem (for example, running a single test from IDE is not support) but I think that will come.
    j
    r
    • 3
    • 8
  • e

    Eugen Martynov

    02/12/2018, 5:11 PM
    It says I wanted to check
    verify(analyticsMock).reportEvent(BUDGETS_EDIT_EVENT_NAME, true)
    d
    • 2
    • 3
  • h

    Hugo

    03/07/2018, 10:12 AM
    hi i'm new to tests and i am trying to setup a CI (gitlab-ci), i'm using spek for my tests and when i run ./gradlew test, it does not run the Spek's tests, is there any specific command line or gradle configs to run thoses test ? thanks
    j
    • 2
    • 2
  • c

    codyoss

    05/25/2018, 8:16 PM
    Anyone ever done Kotlin + Spock + Spring Integration Testing? And if so any public examples of getting the whole context up and running 😁
    a
    p
    • 3
    • 4
  • m

    markusa

    05/30/2018, 4:28 PM
    what is the correct issue tracker to raise issues about
    kotlin.test
    ? What the assertions test result in different outcomes on different platforms
    i
    • 2
    • 1
  • k

    Katie Levy

    06/07/2018, 4:25 PM
    For Jacoco code coverage, has anyone come up with a work-around to ignore the auto-generated methods created from kotlin data classes (ie. getters/setters/equals/hashcode/toString)?
    ➕ 2
    c
    e
    • 3
    • 3
  • g

    ghedeon

    06/09/2018, 10:05 PM
    what is the kotlin equivalent AssertJ library? I'm looking for fluent assertions and seems, unlike in Java, there is no a clear state of the art library for kotlin. Kluent? assertK? fest-assert?
    d
    • 2
    • 1
  • g

    ghedeon

    06/10/2018, 10:20 AM
    should have asked first: which testing framework do you prefer? Junit, KotlinTest, Spek?
    o
    a
    d
    • 4
    • 8
  • h

    hastebrot

    06/13/2018, 10:48 PM
    Kotlin 1.2.50 now provides a
    org.jetbrains.kotlin:kotlin-test-junit5:1.2.50
    dependency for JUnit 5.
    👍 2
    🔥 1
    g
    i
    • 3
    • 2
  • p

    pablisco

    06/20/2018, 2:03 PM
    I'm having an issue with mockito. I'm trying to use the inline mock maker (for Kotlin finals) but in some of the java tests it returns actual objects instead of mocks. Anybody observed this before?
    o
    d
    +2
    • 5
    • 15
  • a

    aandreyev

    07/12/2018, 1:42 PM
    Just curious 1. Has anyone tried using Gatling DSL from Kotlin? 2. Or maybe there are Kotlin performance frameworks/tools similar to Gatling?
    l
    w
    • 3
    • 3
  • j

    jakubgruber

    07/16/2018, 9:46 AM
    Hi, does anyone use Mockk? How do you test asynchronous code as there’s no
    timeout
    keyword similar to Mockito?
    👍 1
    s
    • 2
    • 1
  • g

    grzegorz.olowka

    08/10/2018, 6:49 AM
    Hi guys, I have question. I'am writing a library to communication with my backend. I'am using retrofit and rxjava to service endpoint. What I should test and what I should use to tests api, some library etc?
    o
    • 2
    • 5
  • d

    dave08

    09/12/2018, 2:31 PM
    Could it be that upgrading Gradle (from 4.4 to 4.7,4.10, I had to for some other dependency...) causes
    Empty test suite.
    in Android Studio? I also updated the gradle plugin to 3.1.5. I have mixed Spek & JUnit tests.
    n
    • 2
    • 1
  • k

    keturn

    10/06/2018, 1:50 AM
    is there an assertion I can make in TestNG that would make that more visible?
    w
    • 2
    • 2
  • k

    keturn

    10/10/2018, 3:13 AM
    atrium's block syntax can do better but
    property(subject::x).toBe(...)
    is a lot of extra words.
    d
    r
    • 3
    • 4
  • i

    ivano

    11/01/2018, 7:19 AM
    HI how can I test this method isOpenOrClosed? Namely this `when`:
    n
    • 2
    • 2
  • s

    Sergio Crespo Toubes

    11/07/2018, 10:38 AM
    What do you think is the best combination for testing android application with kotlin? Spek vs KotlinTest, mockk vs mockito-kotlin???? Thanks
    d
    i
    +2
    • 5
    • 7
  • j

    Jake

    11/20/2018, 3:29 PM
    Anyone here have any experience writing a script that utilizes the
    Terminal
    to launch a specified emulator, check for a binary, install it if not present, then run Appium tests? Could you point me in the right direction?
    a
    • 2
    • 2
  • a

    arekolek

    11/26/2018, 11:49 AM
    I did this at least once and it seemed fine with everybody
    t
    • 2
    • 1
  • a

    am

    11/27/2018, 11:12 AM
    Hey folks I wanted to know how can we capture lamda arguments using argument captor, I am able to do when lamda values contains single value ,but how to cature more than one
    
    
     Single argument
    
      api.doSomething(function1:(value:String)->Unit){
    
      	//doSomeStruff
      		function1.invoke("SOME_VALUE")
    
      }
    Case 1
    val mockfunction = mock<((value: String) -> Unit)>()
      api.doSomething(mockfuntion)
    val captor = argumentCaptor<String>()
     verify(mockfunction).invoke(captor.capture)
    
    Case 2:
    
     Can you guys guide me how can we test for than one argument
    
    
      api.doSomething(function1:(title:String,message:String)->Unit){
    
      	//doSomeStruff
      		function1.invoke("SOME_VALUE","SOME_VALUE")
    
      }
    
      val mockFunction = mock<(title: String, message: String) -> Unit>()
    
    val captor = argumentCaptor<((title: String, message: String) -> Unit)>()
    
    ^^ Not sure is this the correct way to do for the above or how to verify the arguments
    o
    • 2
    • 6
Powered by Linen
Title
a

am

11/27/2018, 11:12 AM
Hey folks I wanted to know how can we capture lamda arguments using argument captor, I am able to do when lamda values contains single value ,but how to cature more than one


 Single argument

  api.doSomething(function1:(value:String)->Unit){

  	//doSomeStruff
  		function1.invoke("SOME_VALUE")

  }
Case 1
val mockfunction = mock<((value: String) -> Unit)>()
  api.doSomething(mockfuntion)
val captor = argumentCaptor<String>()
 verify(mockfunction).invoke(captor.capture)

Case 2:

 Can you guys guide me how can we test for than one argument


  api.doSomething(function1:(title:String,message:String)->Unit){

  	//doSomeStruff
  		function1.invoke("SOME_VALUE","SOME_VALUE")

  }

  val mockFunction = mock<(title: String, message: String) -> Unit>()

val captor = argumentCaptor<((title: String, message: String) -> Unit)>()

^^ Not sure is this the correct way to do for the above or how to verify the arguments
o

oleksiyp

11/27/2018, 11:14 AM
If something is not working tell me that 😄
a

am

11/27/2018, 11:14 AM
???
o

oleksiyp

11/27/2018, 11:15 AM
Im mockk author
a

am

11/27/2018, 11:20 AM
ok let me try to elaborate if I have only argument passed in lambda as stated in case 1, when I call captor.invoke with the appropriate class i.e the string value that needs to capture But in case 2 I try to capture the arguments using specified captor but when
capture()
is invoked it gets me a function object, this is wrong ,but I do not know how to capture the multiple arguments,thats passed, for actual code it does pass strings
Wrote first test in kotlin
o

oleksiyp

11/27/2018, 11:26 AM
You can call the function in
answers
, not much I think except that
View count: 4