1

I'm new at unit tests, and i'm developing a Kotlin project, so i thought that it would be great to use a Kotlin based framework.

I've been having problems when adding dependencies to my project. Does anyone now if Kotest can be used in Gradle <6?? Or is there any external dependency Kotest needs to work properly?

Adding the following dependencies, the runner does not detect "any runnable method":

testImplementation 'io.kotest:kotest-runner-junit5:4.6.1'
testImplementation "io.kotest:kotest-assertions-core:4.6.1"

My unit test code is the following:

package com.consumerfinance.nowpay

import io.kotest.core.spec.style.AnnotationSpec
import junit.framework.Assert.assertEquals


/**
 * Example local unit test, which will execute on the development machine (host).
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */

class ExampleUnitTest : AnnotationSpec() {

    @Test
    fun addition_isCorrect() {
        assertEquals(4, 2 + 2)
    }
}
  • Did you add the junit platform plugin as mentioned here: https://kotest.io/docs/quickstart/#test-framework ? Also to start out I'd think it would be more logical to first start with plain old junit instead of starting with an advanced multiplatform library (as it seems like you are targeting only JVM, not multiplatform). See the official kotlin docs for a minimal example: https://kotlinlang.org/docs/jvm-test-using-junit.html – somethingsomething Jul 30 '21 at 10:24

0 Answers0