Skip to content

feat: Enhance test coverage #4847

Merged
jamesarich merged 37 commits intomainfrom
feat/expand-testing
Mar 19, 2026
Merged

feat: Enhance test coverage #4847
jamesarich merged 37 commits intomainfrom
feat/expand-testing

Conversation

@jamesarich
Copy link
Copy Markdown
Collaborator

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:

  • Adopted Kotest for property-based and data-driven testing across multiplatform modules, replacing the previous "consider evaluating" language with a clear directive. [1] [2]
  • Updated testing guidelines in project documentation to recommend Turbine for Flow testing, Kotest for property-based testing, and Mokkery for mocking in commonTest.

Test coverage expansion and implementation:

  • Replaced the old testing track plan with a detailed, checkpointed implementation plan (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]
  • Added new property-based and multiplatform tests, including:
    • Property-based tests for StreamInterface and PacketHandlerImpl using Kotest. [1] [2] [3]
    • Additional unit tests for domain use cases such as SetLocaleUseCase and SetNotificationSettingsUseCase. [1] [2]

Build and dependency updates:

  • Added Kotest dependencies (kotest.assertions, kotest.property) to core:data and core:network test source sets. [1] [2]

Repository and codebase refactoring:

  • Refactored the TracerouteSnapshotRepository to an interface and provided an implementation class, improving separation of concerns and multiplatform compatibility. [1] [2]

Documentation and project planning:

  • Updated and clarified testing-related documentation and removed outdated track references. [1] [2]

These changes collectively modernize the project's testing approach, improve reliability, and provide a clear roadmap for future test coverage efforts.

@github-actions github-actions bot added the enhancement New feature or request label Mar 19, 2026
Signed-off-by: James Rich <[email protected]>
@jamesarich jamesarich requested a review from Copilot March 19, 2026 02:06

This comment was marked as outdated.

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]>
@jamesarich jamesarich requested a review from Copilot March 19, 2026 02:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:* and core:* 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, and TracerouteSnapshotRepository into 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.

Comment on lines 3 to 4
This file tracks all major tracks for the project. Each track has its own detailed plan in its respective folder.

Comment on lines +144 to +146
// Provide data from 2 hours ago (7200 seconds)
// This should make ONE_HOUR available, but not TWENTY_FOUR_HOURS
val twoHoursAgo = now - 7200
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 19, 2026

Codecov Report

❌ Patch coverage is 0.59524% with 167 lines in your changes missing coverage. Please review.
✅ Project coverage is 10.13%. Comparing base (1b0dc75) to head (b8f36da).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...node/domain/usecase/CommonGetNodeDetailsUseCase.kt 0.00% 115 Missing ⚠️
...ic/feature/node/detail/CommonNodeRequestActions.kt 0.00% 51 Missing ⚠️
...ata/repository/TracerouteSnapshotRepositoryImpl.kt 0.00% 1 Missing ⚠️
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     
Flag Coverage Δ
host-unit 10.13% <0.59%> (+2.49%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jamesarich jamesarich added this pull request to the merge queue Mar 19, 2026
Merged via the queue into main with commit 06b9f8c Mar 19, 2026
14 checks passed
@jamesarich jamesarich deleted the feat/expand-testing branch March 19, 2026 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants