The integration test of Spring boot application always starts the web server firstly.
The simplest test of spring boot test looks like below, how does migrate it using kotlintest instead?
@ExtendWith(SpringExtension::class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class ReportApplicationTests {
@Test
fun `Server can be launched`() {
}
}
Here's how I've got it set up: firstly, make sure to reference JUnit 5 instead of 4, e.g. I've got this in the
dependenciessection of mybuild.gradle:Also add this to
build.gradle:Then in your integration test class have this (notice the override of
listeners, without which it won't work):Obviously you can replace
StringSpecwith any of the other Kotlin Test testing styles, e.g.FunSpec,ShouldSpec, etc.