title: Programmatically skip a test in Spock
body: <p>How do I programmatically skip a test in the Spock framework? I know I can <a href="http://spockframework.github.io/spock/docs/1.0/extensions.html" rel="noreferrer">annotate a test with <code>@Ignore</code></a> to skip it, or use <code>@IgnoreIf</code> to skip tests based on environmental variables and the like. But is there a way to run arbitrary code that decides whether or not a test should run?</p>
  
  <p>For example, let's say I have an integration test that has to connect to a third-party service's sandbox environment. Outages in the service's sandbox environment cause the test to fail. Assuming I've written a method <code>canConnectToService</code> that checks if the test will be able to connect to this service, how do I write a test that will be skipped if <code>canConnectToService()</code> returns false?</p>