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
This commit is contained in:
Stephane Nicoll 2014-05-26 15:40:38 +02:00
parent b3022fd24a
commit a51739c0e1
1 changed files with 17 additions and 0 deletions

View File

@ -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 <<howto-discover-the-http-port-at-runtime>> 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