Conversation
…t to use Turbine and Mokkery
…documentation' as complete
Signed-off-by: James Rich <[email protected]>
This commit improves test reliability and execution speed by migrating multiple ViewModel tests from `StandardTestDispatcher` to `UnconfinedTestDispatcher`. It also ensures correct dependency injection for node-related features.
Specific changes include:
- **Testing Infrastructure:**
- Switched to `UnconfinedTestDispatcher` in `BaseMapViewModelTest`, `NodeDetailViewModelTest`, `ContactsViewModelTest`, `QuickChatViewModelTest`, and `SharedContactViewModelTest` to simplify coroutine testing and ensure immediate state updates.
- Updated `runTest` calls to explicitly use the `testDispatcher`.
- Refactored `addQuickChatAction` and `addSharedContact` test cases to join jobs rather than relying on `testScheduler.runCurrent()`.
- Fixed a test initialization issue in `BaseMapViewModelTest` by explicitly setting an initial `Disconnected` state on the fake radio controller.
- **Dependency Injection:**
- Explicitly defined interface bindings for `@Single` annotated classes:
- `CommonNodeRequestActions` now binds to `NodeRequestActions`.
- `CommonGetNodeDetailsUseCase` now binds to `GetGetNodeDetailsUseCase`.
- **CI/CD:**
- Updated `reusable-check.yml` to ignore missing files when uploading Android test results, preventing workflow failures when no tests are run.
Signed-off-by: James Rich <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR modernizes and expands the Kotlin Multiplatform test strategy by standardizing on Turbine (Flow assertions), Mokkery (mocking), and adding Kotest-based property tests, while also refactoring a few APIs (use cases/actions/repositories) to be interface-driven for better testability and KMP compatibility.
Changes:
- Added/refactored multiplatform ViewModel and use case tests across
feature:*andcore:*modules using Turbine + Mokkery. - Introduced Kotest property-based tests for transport/parsing and handler robustness, and wired Kotest deps into relevant modules.
- Refactored
GetNodeDetailsUseCase,NodeRequestActions, andTracerouteSnapshotRepositoryinto interfaces with concrete implementations.
Reviewed changes
Copilot reviewed 38 out of 41 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| feature/node/src/commonTest/kotlin/org/meshtastic/feature/node/metrics/MetricsViewModelTest.kt | Refactors and expands Metrics VM tests using Turbine/Mokkery. |
| feature/node/src/commonTest/kotlin/org/meshtastic/feature/node/domain/usecase/GetFilteredNodesUseCaseTest.kt | Migrates test to kotlin.test + Mokkery. |
| feature/node/src/commonTest/kotlin/org/meshtastic/feature/node/detail/NodeDetailViewModelTest.kt | Adds Turbine/Mokkery coverage for NodeDetailViewModel. |
| feature/node/src/commonTest/kotlin/org/meshtastic/feature/node/compass/CompassViewModelTest.kt | Adds CompassViewModel flow/state tests. |
| feature/node/src/commonMain/kotlin/org/meshtastic/feature/node/metrics/MetricsViewModel.kt | Updates import to use repository interface for traceroute snapshots. |
| feature/node/src/commonMain/kotlin/org/meshtastic/feature/node/domain/usecase/GetNodeDetailsUseCase.kt | Refactors use case into an interface for easier mocking/DI. |
| feature/node/src/commonMain/kotlin/org/meshtastic/feature/node/domain/usecase/CommonGetNodeDetailsUseCase.kt | Adds concrete implementation bound to the new interface. |
| feature/node/src/commonMain/kotlin/org/meshtastic/feature/node/detail/NodeRequestActions.kt | Refactors actions into an interface. |
| feature/node/src/commonMain/kotlin/org/meshtastic/feature/node/detail/CommonNodeRequestActions.kt | Adds concrete implementation bound to the new actions interface. |
| feature/messaging/src/commonTest/kotlin/org/meshtastic/feature/messaging/ui/contact/ContactsViewModelTest.kt | Adds ContactsViewModel tests with Turbine/Mokkery. |
| feature/messaging/src/commonTest/kotlin/org/meshtastic/feature/messaging/QuickChatViewModelTest.kt | Adds QuickChatViewModel tests with Turbine/Mokkery. |
| feature/messaging/src/commonTest/kotlin/org/meshtastic/feature/messaging/MessageViewModelTest.kt | Cleans up types/imports in existing tests. |
| feature/map/src/commonTest/kotlin/org/meshtastic/feature/map/BaseMapViewModelTest.kt | Replaces commented bootstrap tests with Turbine-based assertions. |
| feature/intro/src/commonTest/kotlin/org/meshtastic/feature/intro/IntroViewModelTest.kt | Converts bootstrap tests to kotlin.test assertions. |
| docs/testing/final_coverage.md | Adds final Kover coverage report snapshot. |
| docs/testing/baseline_coverage.md | Adds baseline Kover coverage report snapshot. |
| core/ui/src/commonTest/kotlin/org/meshtastic/core/ui/viewmodel/ConnectionsViewModelTest.kt | Adds ConnectionsViewModel unit tests with Mokkery. |
| core/ui/src/commonTest/kotlin/org/meshtastic/core/ui/share/SharedContactViewModelTest.kt | Adds SharedContactViewModel tests with Turbine/Mokkery. |
| core/ui/src/commonTest/kotlin/org/meshtastic/core/ui/emoji/EmojiPickerViewModelTest.kt | Adds EmojiPickerViewModel tests for prefs delegation. |
| core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/util/AlertManager.kt | Makes methods/properties open to allow mocking in tests. |
| core/ui/build.gradle.kts | Adds Kotest assertion/property deps for commonTest. |
| core/repository/src/commonMain/kotlin/org/meshtastic/core/repository/TracerouteSnapshotRepository.kt | Introduces repository interface for traceroute snapshots. |
| core/network/src/commonTest/kotlin/org/meshtastic/core/network/transport/StreamFrameCodecTest.kt | Adds Kotest property tests for codec inverse/robustness. |
| core/network/src/commonTest/kotlin/org/meshtastic/core/network/radio/StreamInterfaceTest.kt | Adds property tests + connect behavior verification for StreamInterface. |
| core/network/build.gradle.kts | Adds Kotest deps for commonTest. |
| core/domain/src/commonTest/kotlin/org/meshtastic/core/domain/usecase/settings/SetNotificationSettingsUseCaseTest.kt | Adds missing unit tests for notification settings use case. |
| core/domain/src/commonTest/kotlin/org/meshtastic/core/domain/usecase/settings/SetLocaleUseCaseTest.kt | Adds missing unit tests for locale use case. |
| core/data/src/commonTest/kotlin/org/meshtastic/core/data/manager/PacketHandlerImplTest.kt | Adds initialization + property test coverage for queue status handling. |
| core/data/src/commonMain/kotlin/org/meshtastic/core/data/repository/TracerouteSnapshotRepositoryImpl.kt | Renames/updates implementation to implement new repository interface. |
| core/data/src/commonMain/kotlin/org/meshtastic/core/data/manager/TracerouteHandlerImpl.kt | Updates import to new traceroute snapshot repository interface. |
| core/data/build.gradle.kts | Adds Kotest deps for commonTest. |
| conductor/tracks/expand_testing_20260318/plan.md | Removes old, uncheckpointed plan file. |
| conductor/tracks.md | Removes the track listing entry for “Expand Testing Coverage”. |
| conductor/tech-stack.md | Updates guidance to explicitly use Kotest for property-based testing. |
| conductor/archive/expand_testing_20260318/spec.md | Adds archived track specification document. |
| conductor/archive/expand_testing_20260318/plan.md | Adds archived, checkpointed implementation plan. |
| conductor/archive/expand_testing_20260318/metadata.json | Adds archived track metadata. |
| conductor/archive/expand_testing_20260318/index.md | Adds archive index linking spec/plan/metadata. |
| GEMINI.md | Updates testing guidance to include Turbine/Kotest/Mokkery. |
| AGENTS.md | Updates testing guidance to include Turbine/Kotest/Mokkery. |
| .github/workflows/reusable-check.yml | Makes Android report upload non-fatal when no files are found. |
You can also share your feedback on Copilot code review. Take the survey.
| This file tracks all major tracks for the project. Each track has its own detailed plan in its respective folder. | ||
|
|
| // Provide data from 2 hours ago (7200 seconds) | ||
| // This should make ONE_HOUR available, but not TWENTY_FOUR_HOURS | ||
| val twoHoursAgo = now - 7200 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4847 +/- ##
=========================================
+ Coverage 7.63% 10.13% +2.49%
=========================================
Files 544 545 +1
Lines 18071 18095 +24
Branches 2689 2697 +8
=========================================
+ Hits 1380 1834 +454
+ Misses 16557 16081 -476
- Partials 134 180 +46
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
This pull request significantly expands and modernizes the project's multiplatform testing strategy. It introduces property-based testing with Kotest, standardizes the use of Turbine and Mokkery for ViewModel and business logic tests, and fills gaps in domain logic test coverage. The changes also update documentation and refactor repository interfaces for clarity and multiplatform compatibility.
Testing strategy improvements:
Kotestfor property-based and data-driven testing across multiplatform modules, replacing the previous "consider evaluating" language with a clear directive. [1] [2]Turbinefor Flow testing,Kotestfor property-based testing, andMokkeryfor mocking incommonTest.Test coverage expansion and implementation:
plan.md) that covers baseline measurement, migration to Turbine/Mokkery, property-based tests with Kotest, domain logic gap fill, and documentation updates. [1] [2] [3]StreamInterfaceandPacketHandlerImplusing Kotest. [1] [2] [3]SetLocaleUseCaseandSetNotificationSettingsUseCase. [1] [2]Build and dependency updates:
kotest.assertions,kotest.property) tocore:dataandcore:networktest source sets. [1] [2]Repository and codebase refactoring:
TracerouteSnapshotRepositoryto an interface and provided an implementation class, improving separation of concerns and multiplatform compatibility. [1] [2]Documentation and project planning:
These changes collectively modernize the project's testing approach, improve reliability, and provide a clear roadmap for future test coverage efforts.