From 3f9a2aa14556a2301e4767dbf314c77869c03f32 Mon Sep 17 00:00:00 2001 From: Yunkun Huang Date: Thu, 19 Nov 2015 13:13:06 +0800 Subject: [PATCH] Document randomPort attribute on WebIntegrationTest Closes gh-4548 --- .../src/main/asciidoc/spring-boot-features.adoc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 42289ac18a..3c2b314aec 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -3844,6 +3844,21 @@ in order to run your integration tests using random ports. For example: } ---- +Alternatively, you can use the `randomPort` convenience attribute to set `server.port=0`. +For example: + +[source,java,indent=0,subs="verbatim,quotes,attributes"] +---- + @RunWith(SpringJUnit4ClassRunner.class) + @SpringApplicationConfiguration(MyApplication.class) + @WebIntegrationTest(randomPort = true) + public class SomeIntegrationTests { + + // ... + + } +---- + See <> for a description of how you can discover the actual port that was allocated for the duration of the tests.