I have a simple JUnit "smoke" test which check if Spring context is loaded correctly:
@SpringBootTest
class ContextLoadJUnit {
@Test
fun contextLoads() {
//empty by design
}
}
I'm trying to rewrite it into kotest. I've tested two versions:
@SpringBootTest
@ApplyExtension(SpringTestExtension::class)
class ContextLoadKotestWordSpec : WordSpec({
"context" should { "load with WordSpec" {} }
})
@SpringBootTest
class ContextLoadKotestFunSpec : FunSpec() {
override fun extensions(): List<Extension> {
return listOf(SpringExtension)
}
init {
test("context should load with FunSpec") {}
}
}
I have all three tests in one file:
import io.kotest.core.extensions.ApplyExtension
import io.kotest.core.extensions.Extension
import io.kotest.core.spec.style.FunSpec
import io.kotest.core.spec.style.WordSpec
import io.kotest.extensions.spring.SpringExtension
import io.kotest.extensions.spring.SpringTestExtension
import org.junit.jupiter.api.Test
import org.springframework.boot.test.context.SpringBootTest
@SpringBootTest
class ContextLoadJUnit {
@Test
fun contextLoads() {
//empty by design
}
}
@SpringBootTest
@ApplyExtension(SpringTestExtension::class)
class ContextLoadKotestWordSpec : WordSpec({
"context" should { "load with WordSpec" {} }
})
@SpringBootTest
class ContextLoadKotestFunSpec : FunSpec() {
override fun extensions(): List<Extension> {
return listOf(SpringExtension)
}
init {
test("context should load with FunSpec") {}
}
}
When they are running and passing, they are handled correctly:
But when they are failing, kotest are "wrapped" into initializationError
and it looks like I have only two tests:
Is there a way to prepare kotest somehow differently, avoid the initializationError
and see that I have three separate failing tests?