androidx.arch.core:core-testing
Official Description: Android Core-Testing
CommonsWare’s Notes
This artifact provides InstantTaskExecutorRule
. That can be used from JUnit-based
tests to replace the Architecture Components’ standard Executor
with one
that runs everything on the current thread. This turns formerly asynchronous
operations into synchronous ones, which streamlines testing. InstantTaskExecutorRule
is good for testing LiveData
, particularly when returned from Room.
Documentation
Knowledge
- Testing LiveData in JUnit 4 and JUnit 5 (2019-01-17)
- Effective LiveData and ViewModel Testing (2018-06-30)
- Testing ViewModel in MVVM using LiveData and RxJava
Samples
- Exploring Android: CommonsWare’s hands-on tutorial book uses
InstantTaskExecutorRule
in its tests - Basic RxJava Samples (Java): Uses
InstantTaskExecutorRule
in both instrumented and unit tests - Basic RxJava Samples (Kotlin): Same sample as above, converted to Kotlin
Versions
- Latest Stable: 2.1.0
- Latest Release Candidate: 2.1.0-rc01
- Latest Beta: 2.1.0-beta01
- Latest Alpha: 2.1.0-alpha02