Reputation: 16179
I want to do unit test for livedata.
Then @get:Rule var taskExecutorRule = InstantTaskExecutorRule()
should the right direction to go.
bulild.gradle
testImplementation libs.core.testing
catalog
coreTesting = "2.2.0"
core-testing = { module = "androidx.arch.core:core-testing", version.ref = "coreTesting"
I check the answer like this: https://stackoverflow.com/a/56073388/291240
I tried version 2.2.0, 2.1.0 2.0.0 1.0.0 1.1.0, none of them works.
Seems it can be used both in test and instrument test. But not sure the reason why it doesn't work.
Android studio version:
Android Studio Ladybug | 2024.2.1 Patch 3
Build #AI-242.23339.11.2421.12700392, built on November 23, 2024
Runtime version: 21.0.3+-79915917-b509.11 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.lwawt.macosx.LWCToolkit
macOS 15.1.1
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 4096M
Cores: 16
Metal Rendering is ON
Registry:
debugger.new.tool.window.layout=true
ide.experimental.ui=true
i18n.locale=
terminal.new.ui=true
AGP: 8.7.2, grade: 8.9
Thanks for any information!
Upvotes: 0
Views: 29