nextcloud / nextcloud/talk-android

Improve test coverage

Open
#5,165 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

1. to develop enhancement
Dominant language
Kotlin
Stars
739
Forks
321
Avg merge
14h 59m
Merged PRs (30d)
151

Description

Currently our test coverage isn't that great compared to the files app. While full coverage isn't necessary, the point should be to reduce regressions by catching bugs before they occur.

Basically, if we encounter a bug , quirk, or edge case involving our business logic, write a test case for it, so we can make sure it doesn't break again in the future.

This is particularly useful for anything involving room, datastore, date/time, hardware apis (MediaPlayer, AudioRecord, etc), and Networks (Especially anything involving synchronization or offline functionality).

In addition, existing tests in the androidTest directory should be moved to the unit test directory, as with proper separation of concerns, business logic should be in it's own layer, separate from the UI logic, so it can be tested in isolation.

According to best practices we should cover.

Essentials
  • Unit tests for ViewModels, or presenters.
  • Unit tests for the data layer, especially repositories. Most of the data layer should be platform-independent. Doing so enables test doubles to replace database modules and remote data sources in tests. Maybe try using the ComposePreviewUtils and ComposePreviewUtilsDao I made earlier.
  • Unit tests for other platform-independent layers such as the Domain layer, as with use cases and interactors.
  • Unit tests for utility classes such as string manipulation and math.
Edge cases
  • Math operations using negative numbers, zero, and boundary conditions.
  • All the possible network connection errors.
  • Corrupted data, such as malformed JSON.
  • Simulating full storage when saving to a file.
  • Object recreated in the middle of a process (such as an activity when the device is rotated).
Avoid
  • Tests that verify the correct operation of the framework or a library, not your code.
  • Framework entry points such as activities, fragments, or services should not have business logic so unit testing shouldn't be a priority

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing tests in the androidTest directory and the unit test directory, then identify business-logic areas involving Room, datastore, date/time, hardware APIs, and network synchronization. Done means adding regression and edge-case coverage, moving suitable business-logic tests out of androidTest, and keeping framework behavior out of scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile-dev, testing-qa
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.