google / google/ground-android

[Test Coverage] Add Unit Test for CaptureLocationTaskViewModel

Open
#2,519 6 comments 0 reactions 0 assignees View on GitHub
type: code health
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.