Skip to main content
This guide covers testing strategies, practices, and tools for ensuring Divvy’s quality and reliability.

Testing Overview

Divvy’s test suite is designed to cover:
  • Unit tests - Repository logic, ViewModels, and business logic
  • UI tests - Compose screen interactions and user flows
  • Integration tests - End-to-end feature workflows
As of the current codebase snapshot, formal test files are not yet implemented. This guide outlines the recommended testing strategy and setup for contributors.

Testing Stack

Divvy uses the following testing libraries configured in app/build.gradle.kts:1:

Key Dependencies

Project Test Structure

Tests should be organized in the following directories:

Unit Testing

Testing Repositories

Repositories interact with Supabase and should be tested with mocked dependencies.
1

Create repository test file

Add a test file in app/src/test/java/com/example/divvy/backend/:
2

Test error handling

Ensure repositories handle errors gracefully:

Testing ViewModels

ViewModels manage UI state and should be tested for correct state transitions.
1

Create ViewModel test

Add test in app/src/test/java/com/example/divvy/ui/home/:

UI Testing with Compose Test

Compose UI tests verify screen rendering and user interactions.
1

Create UI test file

Add test in app/src/androidTest/java/com/example/divvy/ui/:
2

Test user flows

Verify multi-step interactions:

Compose Test Semantics

Use semantic properties for testability:

Running Tests

Run All Unit Tests

This runs tests in app/src/test/ and outputs results to:

Run All Instrumented Tests

Requires a connected device or emulator:
Results are saved to:

Run Specific Test Class

Run Tests in Android Studio

  1. Right-click on a test file or directory
  2. Select Run ‘Tests in …’
  3. View results in the Run tool window
Instrumented tests run on physical devices or emulators, while unit tests run on the JVM. Use unit tests for fast feedback and instrumented tests for Android-specific behavior.

Test Coverage

While test coverage is not currently configured, you can add JaCoCo for coverage reports:
1

Add JaCoCo plugin

In app/build.gradle.kts:1:
2

Generate coverage report

View report at:

Continuous Integration with Vercel

Divvy uses Vercel for CI/CD as mentioned in the README. While primarily for LLM capabilities (transaction categorization), Vercel can also run tests.
The team is exploring Vercel integration for automated testing on every pull request. Stay tuned for updates in Linear or Discord.
For GitHub Actions or similar CI:

Testing Best Practices

Write Testable Code

  • Inject dependencies: Use Hilt for constructor injection
  • Avoid static state: Use repository patterns, not singletons with mutable state
  • Pure functions: Separate business logic from UI and data layers

Test Naming Conventions

Use descriptive test names:

AAA Pattern

Structure tests with Arrange, Act, Assert:

Mock External Dependencies

Use Mockito to mock Supabase and other external services:

Test Edge Cases

  • Empty lists
  • Null values
  • Network errors
  • Invalid user input

Avoid Testing Implementation Details

Focus on behavior, not internal state:
If tests are brittle and break with every refactor, they’re likely testing implementation details rather than behavior.

Getting Started with Testing

If you’re adding the first tests to Divvy:
1

Start with critical paths

Focus on high-value areas:
  • Authentication flow
  • Expense creation and splitting
  • Group balance calculations
2

Add tests incrementally

Don’t try to reach 100% coverage immediately. Add tests:
  • When fixing bugs (reproduce the bug in a test first)
  • When adding new features (test-driven development)
  • When refactoring (ensure behavior doesn’t change)
3

Document test patterns

Create example test files that others can reference for consistency.

Next Steps