From 324b6321f75b4d2940bee225ace6835a3c7e73dc Mon Sep 17 00:00:00 2001 From: Nicklas Wiegandt Date: Thu, 2 Jul 2026 01:23:26 +0200 Subject: [PATCH] doc: Add RestTestClient setup with @AutoConfigureRestTestClient Signed-off-by: Nicklas Wiegandt --- .../ROOT/pages/testing/resttestclient.adoc | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/framework-docs/modules/ROOT/pages/testing/resttestclient.adoc b/framework-docs/modules/ROOT/pages/testing/resttestclient.adoc index 61bc3eb6bdee..9d15d95cf75f 100644 --- a/framework-docs/modules/ROOT/pages/testing/resttestclient.adoc +++ b/framework-docs/modules/ROOT/pages/testing/resttestclient.adoc @@ -77,6 +77,41 @@ Kotlin:: ---- ====== +[[resttestclient.springboottest-config]] +=== Bind to `@SpringBootTest` + +When using Spring Boot, `@AutoConfigureRestTestClient` auto-configures a `RestTestClient` that connects to the embedded server started by `@SpringBootTest`. + +[tabs] +====== +Java:: ++ +[source,java,indent=0,subs="verbatim,quotes"] +---- + @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) + @AutoConfigureRestTestClient + class HttpRequestTest { + + @Autowired + private RestTestClient restTestClient; + + // ... + } +---- + +Kotlin:: ++ +[source,kotlin,indent=0,subs="verbatim,quotes"] +---- + @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) + @AutoConfigureRestTestClient + class HttpRequestTest(@Autowired private val restTestClient: RestTestClient) { + + // ... + } +---- +====== + [[resttestclient.server-config]] === Bind to Server