Kotest 4 was removed from Micronaut 4 (ref) so I follow this guide to install Kotest 5:
https://micronaut-projects.github.io/micronaut-test/snapshot/guide/index.html#settingUpKoTest5
However, after running the test using ./gradlew test
I got this error.
error: cannot find symbol @MicronautTest()
MyTest.kt
import io.micronaut.test.extensions.kotest5.annotation.MicronautTest
import io.kotest.core.spec.style.AnnotationSpec
@MicronautTest
class MyTest : AnnotationSpec() {
@Test
fun testMyFunc() {
...
}
}
build.gradle.kts
dependencies {
kaptTest ("io.micronaut:micronaut-inject-java")
testImplementation("io.micronaut.test:micronaut-test-kotest5:4.2.0")
testImplementation("io.mockk:mockk:1.13.9")
testImplementation("io.kotest:kotest-runner-junit5-jvm:5.8")
}
tasks.withType<Test>().configureEach {
useJUnitPlatform()
}
micronaut {
...
testRuntime("kotest5")
...
}
ProjectConfig.kt
import io.kotest.core.config.AbstractProjectConfig
import io.micronaut.test.extensions.kotest5.MicronautKotest5Extension
@Suppress("unused")
object ProjectConfig : AbstractProjectConfig() {
override fun extensions() = listOf(MicronautKotest5Extension)
}
- Micronaut version: 4.2.1
- Kotlin version: 1.9.10