You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Getting these error while trying to mock the LiveData object below code is in my class ViewModelClass -
private val _departmentDropDownList = MutableLiveData<List?>()
val departmentDropDownList: LiveData<List?> = _departmentDropDownList TestClass -
mockViewModel = declareMock { when(this.showProgressBar).thenReturn(MutableLiveData(false)) when(this.departmentDropDownList).thenReturn(MutableLiveData(null)) when(this.selectedCompareType).thenReturn("")
val itemList = context.resources.getStringArray(R.array.comparison_type) when(this.getComparisonDropDownList(itemList)).thenReturn(getItemList(itemList))
}
Error which i am getting -
class java.util.ArrayList cannot be cast to class androidx.lifecycle.LiveData (java.util.ArrayList is in module java.base of loader 'bootstrap'; androidx.lifecycle.LiveData is in unnamed module of loader org.robolectric.internal.AndroidSandbox$SdkSandboxClassLoader @4da9f723)
java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class androidx.lifecycle.LiveData (java.util.ArrayList is in module java.base of loader 'bootstrap'; androidx.lifecycle.LiveData is in unnamed module of loader org.robolectric.internal.AndroidSandbox$SdkSandboxClassLoader @4da9f723)
The text was updated successfully, but these errors were encountered:
Getting these error while trying to mock the LiveData object below code is in my class
ViewModelClass -
private val _departmentDropDownList = MutableLiveData<List?>()
val departmentDropDownList: LiveData<List?> = _departmentDropDownList
TestClass -
mockViewModel = declareMock {
when
(this.showProgressBar).thenReturn(MutableLiveData(false))when
(this.departmentDropDownList).thenReturn(MutableLiveData(null))when
(this.selectedCompareType).thenReturn("")val itemList = context.resources.getStringArray(R.array.comparison_type)
when
(this.getComparisonDropDownList(itemList)).thenReturn(getItemList(itemList))}
Error which i am getting -
class java.util.ArrayList cannot be cast to class androidx.lifecycle.LiveData (java.util.ArrayList is in module java.base of loader 'bootstrap'; androidx.lifecycle.LiveData is in unnamed module of loader org.robolectric.internal.AndroidSandbox$SdkSandboxClassLoader @4da9f723)
java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class androidx.lifecycle.LiveData (java.util.ArrayList is in module java.base of loader 'bootstrap'; androidx.lifecycle.LiveData is in unnamed module of loader org.robolectric.internal.AndroidSandbox$SdkSandboxClassLoader @4da9f723)
The text was updated successfully, but these errors were encountered: