-
Notifications
You must be signed in to change notification settings - Fork 0
What is InstantTaskExecutorRule
Devrath edited this page Jul 7, 2021
·
3 revisions
- This is a Junit rule used in test cases for tests that use android architecture components.
- One such scenario is for the execution of
livedata
that happens instantly so that we can use the values in the test.
testImplementation ‘android.arch.core:core-testing:1.1.1’
@get:Rule
val instantTaskExecutorRule = InstantTaskExecutorRule()
- This rule swaps the background executor used by the architecture components with a different one that executes each task synchronously.
- This is very important when writing the unit tests
- Basically, it helps to execute tests one after another in a single thread all at once