I want to use kotest ExpectSpec in Android. But I don't know how to setup Junit5 runner.
This is my app-level build.gradle file
...
android.testOptions {
unitTests.all {
it.useJUnitPlatform()
}
}
dependencies {
...
testImplementation "org.junit.jupiter:junit-jupiter-api:5.8.2"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.8.2"
testImplementation "org.junit.jupiter:junit-jupiter-params:5.8.2"
testImplementation 'junit:junit:4.13.2'
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.8.2"
testImplementation 'org.robolectric:robolectric:4.8'
testImplementation 'androidx.test:core:1.5.0'
testImplementation 'io.kotest:kotest-runner-junit5:5.6.0'
testImplementation "io.mockk:mockk:1.13.4"
testImplementation 'androidx.arch.core:core-testing:2.2.0'
testImplementation "org.jetbrains.kotlin:kotlin-reflect:1.8.20"
debugImplementation "androidx.fragment:fragment-testing:1.6.1"
}
This is my Top-level build.gradle
buildscript {
ext.kotlin_version = '1.7.10'
dependencies {
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "de.mannodermaus.gradle.plugins:android-junit5:1.9.3.0"
}
}
This is my testing code.
import io.kotest.core.spec.style.ExpectSpec
import io.kotest.matchers.shouldBe
class PlusTest : ExpectSpec({
context("plus") {
expect("2 plus 3") {
val result = 2 + 3
result shouldBe 5
}
}
})
How can I run PlusTest?