title: Using SpringBootTest annotation
body: <p>I've built an API using Spring Boot and have a few unit tests associated with it so far. As expected these are ran locally and when Jenkins builds the project via <code>gradle build</code> on the build server. I'm looking to add some integration tests to the project now using rest-assured so I can actually test request and responses but I'm not overly clear how to add them to the project. </p>
  
  <p>So far I've added an integrationTests folder to src/test and have told gradle to exclude the rest-assured tests when <code>gradle build</code> or via <code>gradle test</code> so I can keep them independent. I've setup a gradle task <code>gradle integrationTest</code> to trigger the integration tests which runs fine as long as the API is currently running. </p>
  
  <p>Apparently I can annotate the test class with <code>@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)</code> to instruct spring to start up an embedded server for testing automatically but it doesn't appear to be doing anything, the tests just fail with a <code>java.net.ConnectException</code> error until I start the API in another window. Is there anything wrong with the below sample code or am I missing something else?</p>
  
  <pre><code>com.example.restassured;
  
  import org.junit.Test;
  import org.springframework.boot.test.context.SpringBootTest;
  import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
  
  import static io.restassured.RestAssured.*;
  
  @SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT) 
  public class RunSomeTestsIT {
  
      @Test public void url_should_return_200_response() {
         get("/v1/test/123456").then().statusCode(200);
      }
  
  }
  </code></pre>
  
  <p><strong>build.gradle</strong></p>
  
  <pre><code>task integrationTest(type: Test) {
      include 'com/example/restassured/**'
      // Run all tests each time. Do not cache.
      outputs.upToDateWhen { false } 
  }
  </code></pre>