/AndroidCleanArchitecture

This is an Android Architecture sample written in Kotlin using Clean Architecture and Jetpack components.

Primary LanguageKotlin

Clean Architecture

Summary

This is an Android Architecture sample written in Kotlin using Clean Architecture and Jetpack components.

In this sample you'll find:

  • Two product flavors, dev and prod.
  • Androidx packages fully replace the Support Library.
  • Material Components for Android.
  • A single-activity architecture, using the Navigation component to manage fragment operations.
  • Reactive UIs using LiveData observables and Data Binding.
  • Kotlin Coroutines for background operations.
  • Koin supports lightweight dependency injection.
  • Glide supports the image loading.
  • Timber - A logger with a small, extensible API which provides utility on top of Android's normal Log class.
  • Retrofit - A type-safe HTTP client for Android and Java.
  • An OkHttp interceptor which logs HTTP request and response data.
  • Chucker simplifies the inspection of HTTP(S) requests/responses, and Throwables fired by your Android App.
  • LeakCanary - A memory leak detection library for Android.
  • Mockk supports mocking for Kotlin testing.
  • Local unit tests evaluate your app's logic more quickly and don't need the fidelity and confidence associated with running tests on a real device.
  • MockWebServer - A scriptable web server for testing HTTP clients
  • Robolectric supports running in a simulated Android environment inside a JVM.
  • JaCoCo generates an aggregated JaCoCo test coverage report for all sub-projects.

Structure

  • Presentation: The Views (Fragments or Activities) will interact with ViewModels which access the business logic through use cases.
  • Domain: Holds all business logic and use cases represent all the possible actions able to being performed by the presentation module.
  • Data: Contains all repository implements to access local or remote data

Testing

The project uses local unit tests that run on your computer. To run it and generate a coverage report, you can run: ./gradlew jacocoFullReport

You can see this report at: ./build/reports/jacoco/html/index.html

You can easily write Unit Test up to 70% code coverage lines of code (LOC), if you write focus on

  • Presentation: ViewModel, Mapper
  • Domain: UseCase, Repository, Exception handlers
  • Data: API service, local (database, shared preferences), RepositoryImpl, Mapper

References