-
-
Save darekmydlarz/06105f1a5b3d46e80a38 to your computer and use it in GitHub Desktop.
HOWTO ignore spock tests when gradle is run offline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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' | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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