Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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