From 8116f243aa7e8350d147c656c4647346809a3159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20Ochagav=C3=ADa?= Date: Mon, 1 Dec 2025 20:50:06 +0100 Subject: [PATCH] Use the right annotations in integration test class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tests were failing for me until I added these annotations, so here's a fix. Signed-off-by: Adolfo OchagavĂ­a --- README.adoc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/README.adoc b/README.adoc index b7fc7a1..a60ff0f 100644 --- a/README.adoc +++ b/README.adoc @@ -359,7 +359,11 @@ For the sake of this example, let's create an integration test in order to demon `src/test/kotlin/com/example/blog/IntegrationTests.kt` [source,kotlin] ---- -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@SpringBootTest( + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + classes = [BlogApplication::class] +) +@AutoConfigureTestRestTemplate class IntegrationTests(@Autowired val restTemplate: TestRestTemplate) { @Test @@ -389,7 +393,11 @@ With this configuration, we can now use `@BeforeAll` and `@AfterAll` annotations `src/test/kotlin/com/example/blog/IntegrationTests.kt` [source,kotlin] ---- -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@SpringBootTest( + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + classes = [BlogApplication::class] +) +@AutoConfigureTestRestTemplate class IntegrationTests(@Autowired val restTemplate: TestRestTemplate) { @BeforeAll @@ -714,7 +722,11 @@ And we also update the integration tests accordingly. `src/test/kotlin/com/example/blog/IntegrationTests.kt` [source,kotlin] ---- -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@SpringBootTest( + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + classes = [BlogApplication::class] +) +@AutoConfigureTestRestTemplate class IntegrationTests(@Autowired val restTemplate: TestRestTemplate) { @BeforeAll