diff --git a/app/src/androidTest/java/com/google/maps/android/compose/GoogleMapViewTests.kt b/app/src/androidTest/java/com/google/maps/android/compose/GoogleMapViewTests.kt index fa5b8375..aaefe0c1 100644 --- a/app/src/androidTest/java/com/google/maps/android/compose/GoogleMapViewTests.kt +++ b/app/src/androidTest/java/com/google/maps/android/compose/GoogleMapViewTests.kt @@ -40,6 +40,7 @@ class GoogleMapViewTests { private lateinit var cameraPositionState: CameraPositionState private fun initMap(content: @Composable () -> Unit = {}) { + check(hasValidApiKey) { "Maps API key not specified" } val countDownLatch = CountDownLatch(1) composeTestRule.setContent { GoogleMapView( diff --git a/app/src/androidTest/java/com/google/maps/android/compose/MapInColumnTests.kt b/app/src/androidTest/java/com/google/maps/android/compose/MapInColumnTests.kt index 8d284421..6c7723e3 100644 --- a/app/src/androidTest/java/com/google/maps/android/compose/MapInColumnTests.kt +++ b/app/src/androidTest/java/com/google/maps/android/compose/MapInColumnTests.kt @@ -40,6 +40,7 @@ class MapInColumnTests { private lateinit var cameraPositionState: CameraPositionState private fun initMap(content: @Composable () -> Unit = {}) { + check(hasValidApiKey) { "Maps API key not specified" } val countDownLatch = CountDownLatch(1) composeTestRule.setContent { var scrollingEnabled by remember { mutableStateOf(true) } diff --git a/app/src/androidTest/java/com/google/maps/android/compose/TestUtils.kt b/app/src/androidTest/java/com/google/maps/android/compose/TestUtils.kt index 9ff769a6..c8eb5cad 100644 --- a/app/src/androidTest/java/com/google/maps/android/compose/TestUtils.kt +++ b/app/src/androidTest/java/com/google/maps/android/compose/TestUtils.kt @@ -4,6 +4,9 @@ import com.google.android.gms.maps.model.LatLng import org.junit.Assert.assertEquals import org.junit.Assert.assertNotEquals +val hasValidApiKey: Boolean = + BuildConfig.MAPS_API_KEY.isNotBlank() && BuildConfig.MAPS_API_KEY != "YOUR_API_KEY" + const val assertRoundingError: Double = 0.01 fun LatLng.assertEquals(other: LatLng) {