Skip to content

Instantly share code, notes, and snippets.

@ysb33r
Created May 17, 2014 09:53
Show Gist options
  • Save ysb33r/74574a45c67c9e9e8187 to your computer and use it in GitHub Desktop.
Save ysb33r/74574a45c67c9e9e8187 to your computer and use it in GitHub Desktop.
HOWTO ignore spock tests when gradle is run offline
// 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'
}
}
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
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment