Skip to content

Instantly share code, notes, and snippets.

@darekmydlarz
Forked from ysb33r/build.gradle
Created March 24, 2016 12:42
Show Gist options
  • Save darekmydlarz/06105f1a5b3d46e80a38 to your computer and use it in GitHub Desktop.
Save darekmydlarz/06105f1a5b3d46e80a38 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