Skip to content

test: add comprehensive test suite for places-compose reaching 93.8% coverage - #116

Open
dkhawk wants to merge 1 commit into
ci/workflow-security-hardeningfrom
test/library-coverage-baseline
Open

test: add comprehensive test suite for places-compose reaching 93.8% coverage#116
dkhawk wants to merge 1 commit into
ci/workflow-security-hardeningfrom
test/library-coverage-baseline

Conversation

@dkhawk

@dkhawk dkhawk commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR establishes a comprehensive unit and Compose UI test suite for the :places-compose library, raising project test coverage from 6.4% to 93.8% before any dependency or demo app changes.

Additions:

  1. UnitsTest.kt: Tests Meters value class arithmetic, comparison operators, and extensions (.meters, .m, .km, .feet, .miles, .toFeet, .toMeters, .toKilometers, .toMiles), along with ImperialUnitsConverter vs MetricUnitsConverter threshold formatting. (90.0% coverage)
  2. AddressMapperTest.kt: Tests AddressComponentMultiMap multi-type indexing across all AddressComponentType enum variants, longName and shortName string aggregations, and address conversions. (100.0% coverage)
  3. PlaceMapperTest.kt: Tests converting Places SDK AddressComponent lists to domain Address models. (100.0% coverage)
  4. AutocompleteMapperTest.kt: Tests mapping AutocompletePrediction to AutocompletePlace using MockK. (100.0% coverage)
  5. AutocompleteRepositoryTest.kt: Coroutine unit tests verifying PlacesClient delegation. (100.0% coverage)
  6. ModelsTest.kt: Tests AutocompletePlace attributes, Area and Landmark spatial relationship string resolution, and distance calculations. (73.7% coverage)
  7. AddressDtoTest.kt: Comprehensive unit tests covering reverse geocoding DTO models and Gson serialization. (100.0% coverage)
  8. PlacesAutocompleteTextFieldTest.kt: Robolectric Compose UI test suite covering search field rendering, placeholder, keyboard input, prediction list display, place selection, clear button, back navigation button, @Preview composables, dark theme, and expanded states. (94.1% coverage)

Test Harness Configurations:

  • Updated PublishingConventionPlugin.kt Jacoco configuration with isIncludeNoLocationClasses = true to capture Robolectric classloader execution.
  • Configured places-compose/build.gradle.kts testOptions { unitTests { isReturnDefaultValues = true; isIncludeAndroidResources = true } } and added mockk test dependency.
  • Added places-compose/src/debug/AndroidManifest.xml with ComponentActivity and robolectric.properties with sdk=34.

Part of a stacked PR sequence:

@googlemaps-bot

Copy link
Copy Markdown
Contributor

Code Coverage

Overall Project 86.47% -0.05% 🍏
Files changed 87.5% 🍏

File Coverage
AddressDto.kt 82.68% -0.65% 🍏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants