Skip to content

A sample Android project showcasing unit testing in an MVVM architecture, incorporating Room Database, Retrofit, Repository pattern, and testing of Kotlin Flows and Coroutines using Turbine.

Notifications You must be signed in to change notification settings

bilal96aslam/MVVMTestSuite

Repository files navigation

MVVMTestSuite 🧪

A sample project demonstrating unit testing in an MVVM architecture using Room Database, Retrofit, and Repository pattern in Android.

🚀 Overview

This project demonstrates how to write unit tests for an MVVM-based Android application using Room Database, Retrofit API service, and Repository pattern. The tests cover:

  1. ViewModel tests
  2. Repository tests
  3. Retrofit API service tests
  4. Room Database tests
  5. Room Database tests
  6. Kotlin Flows & Coroutines tests
  7. Turbine for testing Flows

🧪 Unit Tests

The unit tests validate different layers of the MVVM architecture:

  • ViewModel Tests Ensuring correct ViewModel behavior.

  • Repository Tests Mocking data sources and testing repository logic.

  • Retrofit API Tests Mocking API responses.

  • Room Database Tests Testing local database operations.

  • Kotlin Flow & Coroutine Tests Validating asynchronous data streams.

  • Turbine for Flow Testing Ensuring proper emission and collection behavior.

🛠 Tech Stack

  • Kotlin
  • MVVM Architecture
  • Hilt for Dependency Injection
  • Retrofit for API calls
  • Room for local database
  • JUnit & Mockito for Unit Testing
  • Kotlin Coroutines & Flow
  • Turbine for Flow Testing

Getting Started 🏁

  1. Clone the repository:
    git clone https://github.com/bilal96aslam/MVVMTestSuite.git
  2. Open in Android Studio.
  3. Build and run the project.

Contributing 🤝

Contributions are welcome! Feel free to submit issues or pull requests.

About

A sample Android project showcasing unit testing in an MVVM architecture, incorporating Room Database, Retrofit, Repository pattern, and testing of Kotlin Flows and Coroutines using Turbine.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages