Kweku

    Kweku

    1 year ago
    What Testing libraries/ frameworks is everyone using?
    Arkadii Ivanov

    Arkadii Ivanov

    1 year ago
    tjohnn

    tjohnn

    1 year ago
    @Arkadii Ivanov any idea of multiplatform mocking library?
    Arkadii Ivanov

    Arkadii Ivanov

    1 year ago
    AFAIK there is no such a library. Personally I stopped using mocking libraries in any project once I got used to testing without mocking. I use Fakes and Stubs. You can read more about it here: https://medium.com/@june.pravin/mocking-is-not-practical-use-fakes-e30cc6eaaf4e
    Oliver.O

    Oliver.O

    1 year ago
    j

    Jilles van Gurp

    1 year ago
    We use kotest assertions but typically with either junit5 on jvm or kotlin.test (subset of the junit annotations). We don't use the kotest testing dsl. I kind of like the idea of it but it's a bit of a PITA to make work with intellij if you want to just run a single test (it runs everything).
    Kris Wong

    Kris Wong

    1 year ago
    there's mockk, but I try to use mocking sparingly
    there are better patterns
    Vitor Prado

    Vitor Prado

    1 year ago
    I’m writing tests on jvm/android target only. spek + kluent (for assertions) + mockk (for mocking) + turbine (for coroutines-flow testing) Spek and Kotest has the same dsl for testing (rspec spectations style)
    kotest has a builtin assertion lib.. but spek has a simple feature I really like: spek creates a
    memoized
    delegate for properties, it recreates the var for each test.
    Arkadii Ivanov

    Arkadii Ivanov

    1 year ago
    Running tests only on JVM is an option for sure. But please keep in mind that you may miss bugs as follows. This test fails only on JS:
    @Test
    fun foo() {
        val original = Float.MAX_VALUE
        val bits = original.toRawBits()
        val result = Float.fromBits(bits)
        assertEquals(original, result)
    }
    Also there are differences due to K/N memory model, which can also be verified by tests. Etc.
    Javier

    Javier

    1 year ago
    mockk is Multiplatform I think
    but I prefer kotest + fakes
    russhwolf

    russhwolf

    1 year ago
    mockk has no native support, and I think only partial js support
    Kweku

    Kweku

    1 year ago
    @Oliver.O thanks I started with Kotest recently just wondering what else is there
    @Arkadii Ivanov yh I definitely need Native tests, native specific differences especially cos of the memory model is why i'm looking to increase my testing
    Kris Wong

    Kris Wong

    1 year ago
    hmmm I thought i remember using mock w/ KMM, but I guess I just made that up in my head
    m

    marzelwidmer

    1 year ago
    you guyes update also to junit5 the KMM I halso work with koin. or just kotest are fine? I was trying and stop it later again to create setup with jupitor
    Oliver.O

    Oliver.O

    1 year ago
    @Jilles van Gurp Have you ever tried the Kotest IntelliJ Plugin? I'm using it to run single tests from gutter icons or plugin's test explorer. Before trying the plugin, I was using conditional evaluation or Gradle's test filter (
    includeTestsMatching
    ) to single out tests.
    m

    marzelwidmer

    1 year ago
    What I miss here …I try to add Kotest with version 4.4.3… Nothing start….. 😞
    val androidTest by getting {
                dependencies {
                    implementation(kotlin("test-junit"))
                    implementation("junit:junit:4.13.2")
    
                    implementation("io.kotest:kotest-framework-engine:${Versions.kotest}")
                    implementation ("io.kotest:kotest-assertions-core:${Versions.kotest}")
                    implementation ("io.kotest:kotest-property:${Versions.kotest}")
                    implementation ("io.kotest:kotest-runner-junit5-jvm:${Versions.kotest}")
                }
            }
    I have default
    KMM
    gradle setup from the wizard.
    ok at least I get it running on Terminal with adding
    tasks {
        // Tests
        withType<Test> {
            useJUnitPlatform()
        }
    }
    Kweku

    Kweku

    1 year ago
    @marzelwidmer try asking in #kotest
    Javier

    Javier

    1 year ago
    if you run them from gradle they work are working?
    m

    marzelwidmer

    1 year ago
    yes 😞