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

    Robert Menke

    08/13/2019, 8:34 PM
    Does kotlintest have documentation on interceptors? Can’t seem to find it. I basically want to run my tests in a database transaction and then roll back when finished.
    l
    • 2
    • 5
  • i

    igor.wojda

    08/13/2019, 9:48 PM
    What are legitimate reasons (real-live benefits) of migrating Android tests to Junit5… something besides the fact that number
    5
    is cooler that number
    4
    🤔?
    👍 2
    l
    m
    • 3
    • 4
  • j

    jmfayard

    09/04/2019, 9:45 AM
    Does something like
    @VisibleForTesting
    exists in pure Kotlin? On Android we have
    android.support.annotation.VisibleForTesting
    to change the visibility of properties and methods for unit tests.
    t
    e
    m
    • 4
    • 9
  • m

    Marcin Wiśniewski

    09/16/2019, 6:31 PM
    Hi, is there anybody who are using ktor for REST API and has experience in writing IT tests with mocks? Lets assume that I use a kind of service class in my routing. I need to mock that service and test concrete routing / endpoint
    j
    • 2
    • 4
  • l

    Lou Morda

    09/17/2019, 10:48 PM
    Is there a way to run one individual test in a class of lots of tests with IntelliJ? Trying to run one unit test with the run button from sidebar, I think we used to be able to do this...
    ➕ 1
    m
    a
    i
    • 4
    • 6
  • r

    rkeazor

    10/01/2019, 12:37 AM
    Has anyone ran into issue with Mockito and kotlin coroutines. Where testing with verify fails because the continuation is different
    m
    • 2
    • 3
  • r

    rkeazor

    10/09/2019, 12:46 PM
    Anyone here know where good Mockito 3 documentation can be found. or a good talk on Mockito 3... The docs I keep seeing refrence Mockito 2.xx
    r
    • 2
    • 3
  • m

    Marc Knaup

    10/18/2019, 2:51 PM
    How do I unit-test something that is
    DeprecationLevel.HIDDEN
    ? 😄
    r
    • 2
    • 3
  • n

    niklas

    10/22/2019, 3:32 PM
    I am looking for a way to continously compile and run tests, but only those for which dependencies have been recompiled. Basically, has anyone here found a way to replicate what
    sbt testQuick
    does but in Kotlin + JUnit5 (with Gradle)?
    m
    • 2
    • 8
  • u

    ubu

    11/06/2019, 11:40 AM
    @Test
        fun `should emit one account, then two accounts without images`() = runBlockingTest {
    
            val firstAccount = Account(
                id = MockDataFactory.randomUuid(),
                name = MockDataFactory.randomString(),
                avatar = Image(
                    id = MockDataFactory.randomUuid(),
                    sizes = listOf(Image.Size.SMALL)
                )
            )
    
            val secondAccount = Account(
                id = MockDataFactory.randomUuid(),
                name = MockDataFactory.randomString(),
                avatar = Image(
                    id = MockDataFactory.randomUuid(),
                    sizes = listOf(Image.Size.SMALL)
                )
            )
    
            val accounts = flow {
                emit(firstAccount)
                delay(100)
                emit(secondAccount)
            }
    
            val blob = ByteArray(0)
    
            val response = Either.Right(blob)
    
            observeAccounts.stub {
                onBlocking { build() } doReturn accounts
            }
    
            loadImage.stub {
                onBlocking { invoke(any(), any(), any()) } doAnswer { answer ->
                    answer.getArgument<(Either<Throwable, ByteArray>) -> Unit>(2)(response)
                }
            }
    
            vm = buildViewModel()
    
            vm.state.observeForTesting {
    
                advanceTimeBy(1000)
    
                assertEquals(
                    expected = listOf(
                        SelectAccountView.AccountView(
                            id = firstAccount.id,
                            name = firstAccount.name,
                            image = blob
                        ),
                        SelectAccountView.AccountView(
                            id = secondAccount.id,
                            name = secondAccount.name,
                            image = blob
                        )
                    ),
                    actual = vm.state.value
                )
            }
    
            vm.viewModelScope.cancel()
        }
    Why would
    advanceTimeBy
    not work? Test fails: I receive only the first emission containing the first account. I wonder how to test several live data emissions, each being delayed by some interval.
    t
    • 2
    • 2
  • u

    ursus

    12/04/2019, 11:06 AM
    i.e. both dependant on internet as part of the test.. good? bad?
    t
    • 2
    • 7
  • b

    Brendan Weinstein

    01/08/2020, 8:46 PM
    I am trying to use coroutines in some espresso test code, but am getting
    NoSuchMethodError
    .
    java.lang.NoSuchMethodError: No static method runBlocking$default(Lkotlin/coroutines/CoroutineContext;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Ljava/lang/Object; in class Lkotlinx/coroutines/BuildersKt; or its super classes (declaration of 'kotlinx.coroutines.BuildersKt' appears in /data/app/build-acBhKAw8srVGmPVxba9HCw==/base.apk!classes2.dex)
    I have defined rules for
    testProguardFiles
    to do nothing and I have redeclared the coroutines dependency with
    androidTestImplementation
    . Is there a way to force the test code to use a separate classpath for coroutines? Or what's the recommended way to resolve?
    • 1
    • 2
  • t

    tenprint

    01/10/2020, 1:21 PM
    Does anyone TDD hackerrank/leetcode/interview coding questions?
    l
    e
    • 3
    • 12
  • m

    Manuel Lorenzo

    01/13/2020, 9:26 AM
    hi all, It’s the fist time I’m using the paging library and I’m trying to create some instrumented tests but they don’t seem to be working - https://github.com/noloman/WorldHeritages/blob/master/app/src/androidTest/java/me/manulorenzo/worldheritages/ui/main/MainFragmentTest.kt could somebody give me a hand pls? thanks!
    e
    • 2
    • 4
  • a

    Antoine Gagnon

    02/24/2020, 3:26 PM
    Hi all, I’m having some issues where all my instrumentation tests in Android succeed even when I put completely wrong info in my testing function such as:
    class MathTest {
    
        @Test
        fun test_should_fail_function() {
            assert(2.0.pow(24) == 2.0)
        }
    }
    In my build.gradle I have these imports:
    // Android Instrumentation
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation "org.jetbrains.kotlin:kotlin-test-common:$kotlin_version"
    androidTestImplementation "de.mannodermaus.junit5:android-test-core:1.0.0"
    androidTestRuntimeOnly "de.mannodermaus.junit5:android-test-runner:1.0.0"
    Any idea what could be making all of them succeed ?
    r
    d
    • 3
    • 3
  • t

    tim

    03/11/2020, 12:15 PM
    is there an easy way to order kotlin test like junits Order()?
    a
    • 2
    • 10
  • t

    tylerwilson

    03/19/2020, 2:48 PM
    So I have a multiplatform library - Android, iOS and partial JS. What is the latest (unit) testing story for this scenario? That is, should I be able to run tests against the 3 different platforms easily from IntelliJ (I have the Ultimate if needed) or AS? Any up-to-date examples I might look to? Thank you.
    • 1
    • 1
  • g

    Gilberto Diaz

    03/25/2020, 5:31 PM
    How do you test an extension function that is a class member. Lets consider this example
    class DateUtils {
      fun LocalDateTime.setTimeZone(targetTimeZone: String): LocalDateTime {
            return ZonedDateTime.of(
                this,
                ZoneId.of(targetTimeZone)
            ).toLocalDateTime()
        }
    }
    
    @Test
    fun `It should set time zone`() {
      val msgDateStr = "2020-03-07T11:55:00"
      val format = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss")
      al currDate = LocalDateTime.parse(msgDateStr, format)
      assertEquals("2020-03-07T11:55-05:00[America/New_York]", DateUtils.setTimeZone(currDate, "America/NewYork"))
    }
    
    DateUtils.setTimeZome(...) // I get a Unresolved reference: setTimeZone
    d
    a
    • 3
    • 14
  • a

    Antoine Gagnon

    04/16/2020, 3:06 PM
    This might be a dumb question but I can’t seem to figure it out: I create a jacoco test report for tests in both test and androidTest folders of my project. This works fine in local, but when I run it on Jenkins, the UI tests are skipped (literally says SKIPPED next to them in the console) Any idea what could be causing it?
    • 1
    • 1
  • r

    Rita Curado

    04/17/2020, 9:07 AM
    Hi guys, I am using `nhaarman/mockito-kotlin`and I am trying to mock my API class which has a dependency injection. Something like this:
    class Api(s: String) {
     private val name = s
    }
    I am doing this:
    _val apiMock = mock_<Api> { … }
    How can I pass the `s`argument the class needs? Thanks in advance
    t
    m
    • 3
    • 13
  • g

    Gilberto Diaz

    04/17/2020, 5:13 PM
    I’m trying to assert if a function ran inside a
    if() {} else {}
    statement? How I can do that?
    g
    u
    • 3
    • 2
  • u

    ursus

    04/19/2020, 6:15 AM
    That sounds awfully like mockito verify
    c
    • 2
    • 3
  • g

    Gilberto Diaz

    04/22/2020, 5:56 PM
    Untitled
    a
    t
    • 3
    • 7
  • r

    robstoll

    04/25/2020, 9:54 PM
    I just stumbled over https://kotlinlang.org/docs/reference/js-project-setup.html and saw that there is a new gradle plugin for js (maybe kotlin-exmaples should be updated). Maybe its the wrong place to ask but I'll try it nonetheless. Is there a way to define what parameters are passed to mocha so that I can change for instance what reporter is used?
    • 1
    • 1
  • p

    pardom

    04/30/2020, 3:02 PM
    Hey, all. I’m curious if anyone has discovered a way to create “dynamic” multiplatform tests (using
    kotlin.test
    ) similar to the way spekframework and kotest do, rather than writing
    n
    variants for the same test.
    s
    • 2
    • 4
  • a

    Antoine Gagnon

    05/25/2020, 2:49 PM
    Hey everyone! I’ve started writing UI tests using Espresso but I found it is awful to write and read. I’ve picked up Kakao to simplify some of the syntax, but I was wondering if some of you have some preferred library on top of Espresso or alternatives to make writing UI tests easier?
    n
    e
    • 3
    • 4
  • r

    Rodrigo Silva

    06/01/2020, 10:33 PM
    Hello all. I'm using sonarqube + jacoco, but jacoco is not creating xml files. And my coverage is always 0.0%. Could anyone help?
    r
    • 2
    • 1
  • a

    Alex Kuznetsov

    06/10/2020, 10:26 PM
    Hi all, Which library/framework are you using for parameterized tests, and why?
    a
    t
    m
    • 4
    • 3
  • s

    Sam

    06/12/2020, 9:22 AM
    Hello, good morning you guys, I have a small question about testing: What kind of test do you often implement in Startup ( Release many features in a short time) ? Many thanks.
    Small tests are unit tests that validate your app's behavior one class at a time.
    Medium tests are integration tests that validate either interactions between levels of the stack within a module, or interactions between related modules.
    Large tests are end-to-end tests that validate user journeys spanning multiple modules of your app.
    t
    a
    +2
    • 5
    • 13
  • g

    Gaurav

    07/14/2020, 1:54 AM
    Hi, Which framework you are using for running parallel expresso tests? Problem is as we have more test running it in one device take a lot time
    d
    • 2
    • 2
Powered by Linen
Title
g

Gaurav

07/14/2020, 1:54 AM
Hi, Which framework you are using for running parallel expresso tests? Problem is as we have more test running it in one device take a lot time
d

dazza5000

07/15/2020, 10:58 PM
I've used this before: https://github.com/Flank/flank
g

Gaurav

07/16/2020, 2:16 AM
It's for Firebase cloud. I am running it on own infra setup
View count: 2