From a51739c0e1af89f7b517150a4c4ef988146f125d Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 26 May 2014 15:40:38 +0200 Subject: [PATCH] Integration tests documentation This commit clarifies how @IntegrationTest can be used as an alternative of starting the (web) application prior to running the tests suite. Fixes gh-667 --- .../src/main/asciidoc/spring-boot-features.adoc | 17 +++++++++++++++++ 1 file changed, 17 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 81811711b8..50dee734e8 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -1649,7 +1649,24 @@ interaction. For Example: To change the port you can add environment properties to `@IntegrationTest` as colon- or equals-separated name-value pairs, e.g. `@IntegrationTest("server.port:9000")`. +As long as you use the same configuration, the context will be cached amongst different +tests by default. You can therefore use this feature to run a battery of integration tests +where the server would actually start prior to the tests. In that case, it would be better +to make sure that your integration tests use a random port for the main server and the +management one, something like: +[source,java,indent=0,subs="verbatim,quotes,attributes"] +---- + @RunWith(SpringJUnit4ClassRunner.class) + @SpringApplicationConfiguration(classes = MyApplication.class) + @WebAppConfiguration + @IntegrationTest({"server.port=0", "management.port"}) + public class SomeIntegrationTests { ... } + +---- + +See <> for a description of how you can discover +the actual port that was allocated for the duration of the tests. [[boot-features-test-utilities]] === Test utilities