@@ -6,6 +6,7 @@ import org.gradle.api.internal.plugins.PluginApplicationException
66import org.gradle.internal.resolve.ModuleVersionNotFoundException
77import org.gradle.testfixtures.ProjectBuilder
88import spock.lang.IgnoreIf
9+ import spock.lang.Requires
910import spock.lang.Specification
1011
1112/**
@@ -55,6 +56,16 @@ abstract class AndroidJUnitPlatformSpec extends Specification {
5556 return Version . ANDROID_GRADLE_PLUGIN_VERSION . startsWith(" 3." )
5657 }
5758
59+ private static boolean hasInternetAccess () {
60+ try {
61+ // TODO Easier and/or more lightweight detection method?
62+ return InetAddress . getByName(" https://google.com" ). isReachable(1000 )
63+
64+ } catch (UnknownHostException ignored) {
65+ return false
66+ }
67+ }
68+
5869 /* Before Each */
5970
6071 def setup () {
@@ -132,6 +143,8 @@ abstract class AndroidJUnitPlatformSpec extends Specification {
132143 p. tasks. getByName(" junitPlatformTestRelease" )
133144 }
134145
146+ @SuppressWarnings (" UnnecessaryQualifiedReference" )
147+ @Requires ({ AndroidJUnitPlatformSpec .hasInternetAccess() })
135148 def " classpath assembled correctly" () {
136149 when :
137150 // Prepare another test project to link to
@@ -243,7 +256,9 @@ abstract class AndroidJUnitPlatformSpec extends Specification {
243256 p. tasks. getByName(" junitPlatformTestPaidRelease" )
244257 }
245258
246- @IgnoreIf ({ isAgp3x() })
259+ @SuppressWarnings (" UnnecessaryQualifiedReference" )
260+ @IgnoreIf ({ AndroidJUnitPlatformSpec .isAgp3x() })
261+ @Requires ({ AndroidJUnitPlatformSpec .hasInternetAccess() })
247262 def " custom junit jupiter version" () {
248263 when :
249264 def nonExistentVersion = " 0.0.0"
@@ -292,6 +307,7 @@ abstract class AndroidJUnitPlatformSpec extends Specification {
292307 assert expected. message. contains(" $nonExistentVersion " )
293308 break
294309 }
310+
295311 expected = expected. cause
296312 }
297313
0 commit comments