I am working with Kotlin, Micronaut and Kotest5. Setup a functional test directory in gradle. Created functional test in it. Test runs fine, however if I am injecting objects in the test class constructor I am getting this error: Could not create instance of class. Specs must have a public zero-arg constructor.
If I move this test class into the test directory instead of the custom setup functional test directory. And I added io.kotest.provided package with a class in it, here is the class
import io.kotest.core.config.AbstractProjectConfig
import io.micronaut.test.extensions.kotest5.MicronautKotest5Extension
object ProjectConfig : AbstractProjectConfig() {
override fun extensions() = listOf(MicronautKotest5Extension)
}
The test runs with no issue! If I remove this ProjectConfig
class, the same issue comes back. However if I move everything back to the functional test directory even with this ProjectConfig
class, it still does not work. It is like it can not pick up this extension configuration.
Everything like @MicronautTest
, classpath, runtimeClasspath are all set properly. When running tests with injected objects in functional test directory, it just kept giving me that Specs must have a public zero-arg constructor.
error.
Does anyone know how to fix this extension configuration not being picked up by the functional tests issue?