Repository navigation
Conversation
Coverage (unit tests)Compared against
Line and branch coverage from unit test reports. History is recorded on the |
Code Coverage
|
9f260d3 to
bab4d05
Compare
34f2003 to
57c2723
Compare
57c2723 to
a63c557
Compare
bab4d05 to
d74586e
Compare
|
|
||
| val expectedDistance = startLatLng.sphericalDistance(endLatLng) | ||
| val expectedResult = (expectedDistance * 8 / 9).toInt() | ||
|
|
There was a problem hiding this comment.
This repeats the same formula as calculateDistance, so if someone changes the ratio by mistake the test still passes. What about asserting against a known value instead? 0.001° of longitude at the equator is roughly 111 m, so we would expect around 98.
| // Update camera position to trigger visibility LaunchedEffect | ||
| cameraState.position = CameraPosition.fromLatLngZoom(LatLng(37.7749, -122.4194), 14f) | ||
| composeTestRule.waitForIdle() | ||
| } |
There was a problem hiding this comment.
Could we assert something here? Right now the test passes as long as nothing crashes. Setting composeTestRule.mainClock.autoAdvance = false and advancing past visibilityDurationMillis would let us check that the bar shows after the camera change and hides again, which is the actual behaviour of this composable.
| import com.google.common.truth.Truth.assertThat | ||
| import com.google.maps.android.compose.CameraPositionState | ||
| import com.google.maps.android.ktx.utils.sphericalDistance | ||
| import io.mockk.every |
There was a problem hiding this comment.
nit: ScaleBar.kt uses com.google.maps.android.sphericalDistance. Should we use the same one here so the test and the production code stay on the same implementation?
| import io.mockk.every | |
| import com.google.maps.android.sphericalDistance |
Description
Stacked PR on top of #1001 (
feature/robolectric-tests).Introduces JVM unit and Compose integration tests using Robolectric and the local shadow library for
maps-compose-widgets, bringing module line coverage up from 0.00% to 67.12% (instruction coverage from 0.00% to 80.68%).Summary of Changes
robolectric,mockk,truth,androidx.test.compose.ui,maps.robolectric.shadows) inmaps-compose-widgets/build.gradle.kts.ComponentActivityfor Robolectric Compose rule hosting.ScaleBarTest.ktcovering canvas distance calculation, unit conversions (ft, mi),ScaleBarcomposable rendering, andDisappearingScaleBarcamera position animation/state changes.cc @LoyalAbbas @kikoso