Unit testing LiveData observerForever results in NullPointer Exception with Junit5
问题 I am using Android databinding to listen to live data changes and I would like to observe changes on the viewmodel level (Rather then observing on fragment and then sending a callback to the viewmodel) The observerForever is interesting as it serves the purpose for me. However when I run a test I get the following error: java.lang.NullPointerException at androidx.arch.core.executor.DefaultTaskExecutor.isMainThread(DefaultTaskExecutor.java:77) at androidx.arch.core.executor.ArchTaskExecutor