All Projects → jraska → Livedata Testing

jraska / Livedata Testing

Licence: apache-2.0
TestObserver to easily test LiveData and make assertions on them.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Livedata Testing

Githubarchitecturecomponents
The implementation of Android "Architecture Components" sample explained by Google : https://developer.android.com/topic/libraries/architecture/guide.html
Stars: ✭ 302 (-15.64%)
Mutual labels:  architecture-components, livedata
AndroidCleanArchitecture
Android Project with clean android architecture contain Dagger, Retrofit, Retrofit, Android archtecture components, LiveData with MVVM architecture
Stars: ✭ 22 (-93.85%)
Mutual labels:  livedata, architecture-components
Android-MVVM-News-App
MVVM News Application with clean code architecture & android jetpack components.
Stars: ✭ 38 (-89.39%)
Mutual labels:  livedata, architecture-components
Android Architecture Components Kotlin
Sample used to practice Kotlin and Android Architecture Components.
Stars: ✭ 326 (-8.94%)
Mutual labels:  architecture-components, livedata
Architecturecomponentsdemo
Kotlin demo project that uses some Android Architecture Components (ViewModel and LiveData) with Dagger 2 and Coroutines
Stars: ✭ 269 (-24.86%)
Mutual labels:  architecture-components, livedata
TeamManagerApp
A sample app structure using the MVVM architecture LiveData, RxJava, ViewModel, Room and the Navigation Arch Components.
Stars: ✭ 36 (-89.94%)
Mutual labels:  livedata, architecture-components
Simple-Notes-Kotlin-App
✍️ Simple Note Making App use mvvm architecture , dagger , coroutines and navigation component. Features includes 🗒️ create , edit and ❌ delete notes
Stars: ✭ 40 (-88.83%)
Mutual labels:  livedata, architecture-components
Mvvmframe
🏰 MVVMFrame for Android 是一个基于Google官方推出的Architecture Components dependencies(现在叫JetPack){ Lifecycle,LiveData,ViewModel,Room } 构建的快速开发框架。有了MVVMFrame的加持,从此构建一个MVVM模式的项目变得快捷简单。
Stars: ✭ 218 (-39.11%)
Mutual labels:  architecture-components, livedata
movies
An example approach for modularization, reactive clean architecture and persistancy.
Stars: ✭ 110 (-69.27%)
Mutual labels:  livedata, architecture-components
LiveData-DataBinding-Kotlin
Sample to practice LiveData + DataBinding
Stars: ✭ 89 (-75.14%)
Mutual labels:  livedata, architecture-components
Daggerandroidmvvm
Demonstrates using Dagger 2.11+ in MVVM app with Android Architecture Components, Clean Architecture, RxJava
Stars: ✭ 255 (-28.77%)
Mutual labels:  architecture-components, livedata
ReactiveLiveData
Transformation functions for LiveData
Stars: ✭ 80 (-77.65%)
Mutual labels:  livedata, architecture-components
Restaurants
Restaurants sample app built with the new architecture components (LiveData, Room, ViewModel) and Dagger 2
Stars: ✭ 47 (-86.87%)
Mutual labels:  livedata, architecture-components
News Sample App
A sample news app which demonstrates clean architecture and best practices for developing android app
Stars: ✭ 334 (-6.7%)
Mutual labels:  architecture-components, livedata
livedata-recyclerview-sample
No description or website provided.
Stars: ✭ 76 (-78.77%)
Mutual labels:  livedata, architecture-components
KTAndroidArchitecture
A Kotlin android architecture with Google Architecture Components
Stars: ✭ 33 (-90.78%)
Mutual labels:  livedata, architecture-components
Movieapp Clean Architecture
Learning Project (Movie App) For Applying Android Architecture Components And Clean Architecture Using MVVM With Kotlin
Stars: ✭ 123 (-65.64%)
Mutual labels:  architecture-components, livedata
Fountain
Android Kotlin paged endpoints made easy
Stars: ✭ 175 (-51.12%)
Mutual labels:  architecture-components, livedata
Superhero-App
🦸🏻‍♂️🦹🏻‍♀️Superhero app built with Kotlin, ViewModel, LiveData, ViewBinding, Room, and Hilt
Stars: ✭ 27 (-92.46%)
Mutual labels:  livedata, architecture-components
Android-Mvi-Starter
Android MVI Starter application
Stars: ✭ 19 (-94.69%)
Mutual labels:  livedata, architecture-components

JCenter Update

  • LiveData Testing is currently published on JCenter - it will serve packages until February 1st, 2022. LiveData Testing packages will be migrated to Maven Central before that - see issue. Thanks for using LiveData Testing! :)

LiveData Testing

TestObserver to easily test LiveData and make assertions on them.

CircleCI Download License Android Arsenal

Read Medium Article for more info.

Explanatory Diagram

Usage

Having LiveData<Integer> of counter from 0 to 4:

Kotlin - see ExampleTest.kt

liveData.test()
  .awaitValue()
  .assertHasValue()
  .assertValue { it > 3 }
  .assertValue(4)
  .assertHistorySize(5)
  .assertNever { it > 4 }


// Assertion on structures with a lot of nesting
viewLiveData.map { it.items[0].header.title }
  .assertValue("Expected title")

Java - see ExampleTest.java

TestObserver.test(liveData)
  .awaitValue()
  .assertHasValue()
  .assertValue(value -> value > 3)
  .assertValue(4)
  .assertHistorySize(5)
  .assertNever(value -> value > 4);

Don't forget to use InstantTaskExecutorRule from androidx.arch.core:core-testing to make your LiveData test run properly.

Download

Kotlin users:
testImplementation 'com.jraska.livedata:testing-ktx:1.1.2'
Java users:
testImplementation 'com.jraska.livedata:testing:1.1.2'

Philosophy

This library is created in a belief that to effective and valuable test should be fast to write and model real code usage. As by Architecture components spec Activity should communicate with its ViewModel only through observing LiveData. TestObserver in this case simulates the Activity and by testing LiveData, we could test our whole logic except the View where the responsibility belongs to Activity. Key ideas:

  • Test pretends to be an Activity
  • No Android framework mocking or Robolectric - just standard fast JUnit tests
  • Fluent API inspired by RxJava TestObserver
  • Easy to write fast executing tests - possibly TDD
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].