title: How to find port of Spring Boot container when running a spock test using property server.port=0
body: <p>Given this entry in <code>application.properties</code>:</p>
  
  <pre><code>server.port=0
  </code></pre>
  
  <p>which causes Spring Boot to chose a random available port, and testing a spring boot web application using spock, how can the spock code know which port to hit?</p>
  
  <p>Normal injection like this:</p>
  
  <pre><code>@Value("${local.server.port}")
  int port;
  </code></pre>
  
  <p>doesn't work with spock.</p>