crazy4groovy
5/17/2014 - 9:53 AM

HOWTO ignore spock tests when gradle is run offline

HOWTO ignore spock tests when gradle is run offline

class MyAweSomeSpec extends Specification {
  
  // The IgnoreIf annotation will control text execution
  @IgnoreIf( {System.getProperty('TESTS.ARE.OFFLINE')} )
  def "This test must only run when gradle is not in offline mode"() {
    // Do whatever you would normally do in a Spock specification
  }
  
}
// Check whether --offline was passed to gradle and set it in the test configuration's system properties
test {

    if(gradle.startParameter.isOffline()) {
        systemProperties 'TESTS.ARE.OFFLINE' : '1'
    }

}