@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureWebTestClient
@AutoConfigureWireMock(port = PORT)
class InstaControllerTest {
@Autowired
private lateinit var webTestClient: WebTestClient
@Test
fun hello() {
val result = webTestClient.get().uri("/api/v1/hello").exchange().expectBody(String::class.java).returnResult
}
with(result) {
assertThat(status).isEqualTo(HttpStatus.OK)
assertThat(responseBody).isEqualTo("Hello, world!")
}
}
runtimeOnly("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:1.9.0-RC.2")
implementation("org.springframework.boot:spring-boot-starter-webflux")
SpringBootTest.WebEnvironment.RANDOM_PORT 일 때는 @Transactional 로 테스트 이후 롤백할 수 없다.