Skip to content

refactor(test): Introduce MeshTestApplication for robust testing#4602

Merged
jamesarich merged 1 commit intomainfrom
fix/checks
Feb 20, 2026
Merged

refactor(test): Introduce MeshTestApplication for robust testing#4602
jamesarich merged 1 commit intomainfrom
fix/checks

Conversation

@jamesarich
Copy link
Copy Markdown
Collaborator

Adds testing app for Robolectric

This commit introduces a dedicated `MeshTestApplication` class to improve the reliability and efficiency of Robolectric tests. This lightweight application class prevents heavyweight background initializations like WorkManager and DatabaseManager by default, addressing resource leaks and native SQLite issues on the JVM during test runs.

Key changes include:

*   **Test-Specific Application:** A new `MeshTestApplication` is used for Robolectric tests, providing control over the application lifecycle and preventing automatic initialization of services.
*   **Graceful Shutdown:** The main `MeshUtilApplication` now properly cancels its `CoroutineScope` and closes the `DatabaseManager` in `onTerminate()`. The `DatabaseManager` itself also has a new `close()` method to release resources and cancel its scope.
*   **Controlled Initialization:** Tests can now explicitly enable full application initialization when needed by setting a static flag (`MeshTestApplication.shouldInitialize`).
*   **Robolectric Configuration:** A `robolectric.properties` file has been added to configure Robolectric to use the new `MeshTestApplication`.

Signed-off-by: James Rich <[email protected]>
@jamesarich jamesarich added the bugfix PR tag label Feb 20, 2026
@jamesarich jamesarich merged commit ac5a171 into main Feb 20, 2026
6 of 8 checks passed
@jamesarich jamesarich deleted the fix/checks branch February 20, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant