google / google/ground-android
[Test Coverage] Add Unit Test for CaptureLocationTaskViewModel
- Dominant language
- Kotlin
- Stars
- 293
- Forks
- 149
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 42
Description
Add Unit Test for CaptureLocationTaskViewModel
Few Observations:
1. Currently, In the constructor of CaptureLocationTaskViewModel we are passing `Resources`, which is an android component.
2. The idea of ViewModel is to keep it independent from the Android-specific items, like `Resources`.
What is the Current Issue?
The reason the resources is there in the `CaptureLocationTaskViewModel` is because it needs to pass to `AbstractTaskViewModel`.
In `AbstractTaskViewModel` it is only used to access the string from the resources.
How we can fix this?
The `validate` function currently passes the String (resources), rather we can pass a boolean, saying isValid or notValid. The calling site will be responsible for accessing the Android resources.
This way we can make our ViewModel, Android independent
@shobhitagarwal1612 WDYT?
Contributor guide
Assessment
This issue has not been assessed yet.