test: add comprehensive test suite for places-compose reaching 93.8% coverage - #116
test: add comprehensive test suite for places-compose reaching 93.8% coverage#116dkhawk wants to merge 1 commit into
Conversation
Code Coverage
|
| <application> | ||
| <activity | ||
| android:name="androidx.activity.ComponentActivity" | ||
| android:exported="true" /> |
There was a problem hiding this comment.
Do we need this true value, or we can keep this false also ?
There was a problem hiding this comment.
Thanks for catching this! Removed places-compose/src/debug/AndroidManifest.xml entirely since androidx.compose.ui:ui-test-manifest (included via debugImplementation) already provides ComponentActivity for debug testing, eliminating the need for a custom manifest declaration and avoiding manifest merger conflicts.
| travel = 150.0 | ||
| ) | ||
| // When travelDistanceMeters >= 0, returns straightLineDistanceMeters according to implementation | ||
| assertThat(landmarkPositiveTravel.distanceMeters()).isEqualTo(120.meters) |
There was a problem hiding this comment.
Just wanted to double-check this logic—is it intentional?
In models.kt line 108
fun Landmark.distanceMeters(): Meters =
(if (travelDistanceMeters < 0) travelDistanceMeters else straightLineDistanceMeters).meters
It looks like it returns straightLineDistanceMeters when travelDistanceMeters is valid (>= 0), which seems a bit counterintuitive. Let me know if I am missing something.
There was a problem hiding this comment.
Great spot! You're completely right — the condition was inverted. Updated to:
fun Landmark.distanceMeters(): Meters =
(if (travelDistanceMeters >= 0) travelDistanceMeters else straightLineDistanceMeters).metersand updated the corresponding test assertions in ModelsTest.kt.
4b3623d to
5a7b9a8
Compare
Description
This PR establishes a comprehensive unit and Compose UI test suite for the
:places-composelibrary, raising project test coverage from 6.4% to 93.8% before any dependency or demo app changes.Additions:
UnitsTest.kt: TestsMetersvalue class arithmetic, comparison operators, and extensions (.meters,.m,.km,.feet,.miles,.toFeet,.toMeters,.toKilometers,.toMiles), along withImperialUnitsConvertervsMetricUnitsConverterthreshold formatting. (90.0% coverage)AddressMapperTest.kt: TestsAddressComponentMultiMapmulti-type indexing across allAddressComponentTypeenum variants,longNameandshortNamestring aggregations, and address conversions. (100.0% coverage)PlaceMapperTest.kt: Tests converting Places SDKAddressComponentlists to domainAddressmodels. (100.0% coverage)AutocompleteMapperTest.kt: Tests mappingAutocompletePredictiontoAutocompletePlaceusing MockK. (100.0% coverage)AutocompleteRepositoryTest.kt: Coroutine unit tests verifying PlacesClient delegation. (100.0% coverage)ModelsTest.kt: TestsAutocompletePlaceattributes,AreaandLandmarkspatial relationship string resolution, and distance calculations. (73.7% coverage)AddressDtoTest.kt: Comprehensive unit tests covering reverse geocoding DTO models and Gson serialization. (100.0% coverage)PlacesAutocompleteTextFieldTest.kt: Robolectric Compose UI test suite covering search field rendering, placeholder, keyboard input, prediction list display, place selection, clear button, back navigation button,@Previewcomposables, dark theme, and expanded states. (94.1% coverage)Test Harness Configurations:
PublishingConventionPlugin.ktJacoco configuration withisIncludeNoLocationClasses = trueto capture Robolectric classloader execution.places-compose/build.gradle.ktstestOptions { unitTests { isReturnDefaultValues = true; isIncludeAndroidResources = true } }and addedmockktest dependency.places-compose/src/debug/AndroidManifest.xmlwithComponentActivityandrobolectric.propertieswithsdk=34.📚 Stacked PR Chain
ci/workflow-security-hardening(Workflow permissions & action pinning)maintest/library-coverage-baseline(Test suite reaching 93.8% coverage)build/dependency-modernization(AGP 9.3.2, Gradle 9.5.1, Places 5.3.0)feat/places-usage-attribution(Usage attribution & remove:library)demo/ux-edge-to-edge-polish(Demo UX, edge-to-edge, mock location)Umbrella PR: #109