All Questions
276
questions
0
votes
0
answers
27
views
How to identify the best method to test a function in Android Studio?
Below is a function in our Android application designed to update the app with a new installation of its current version. However, each approach I've attempted has encountered significant obstacles, ...
0
votes
0
answers
26
views
How I can test location service, and it's permissions with junit?
Is it possible to write to write instrumental tests and later on for location permissions? I'm relatively new to testing topic, and I haven't found much examples that could possibly help me with it.
0
votes
0
answers
32
views
uiState not updating in Tests
Does anyone have any idea why my uiState is not updated in the tests? The strange thing is that in the app running if it is updated, but when testing the viewmodel and send events does not update the ...
0
votes
0
answers
17
views
Android Test case Intent Response handling if there is no intent in the activity and you just want to write intent only in test class
I have 2 activity 1st activity don't have any intent and the second activity have collection of operation like finger capture and device info and many more if you send intent with setAction "...
0
votes
0
answers
27
views
Could not mock EglBase when trying to write test code
I am trying to write a test code for a function.
public void initializeRenderers() {
if(eglBase == null) {
eglBase = EglBase.create();
}
if(renderersInitiated)...
0
votes
0
answers
94
views
How to migrate TestCoroutineDispatcher to UnconfinedTestDispatcher
I wrote a test for my ViewModel but just realized that TestCoroutineDispatcher is deprecated. It seems that UnconfinedTestDispatcher would be ideal for my tests and I have tried to migrate my test to ...
0
votes
0
answers
76
views
Android Kotlin: Failed StateFlow initialization on fake Repository between test cases in Unit test
I've written unit tests for my viewmodel, which takes a fake repository as a constructor. When I run my insertNote() test standalone, which insert a value to a StateFlow in my repository and evaluates ...
0
votes
0
answers
64
views
Conditional to Ignore Code in Android Unit Tests?
I have a thin wrapper LogWrapper around android.util.Log that I have used throughout most of my code.
When I write unit tests in my code, I often get an error like Method "d" in android.util....
1
vote
0
answers
125
views
Test ViewModel with Jetpack Compose e compose state
I'm getting the following error in my ViewModel test, it's pretty clear, but I can't figure out why.
Parameter specified as non-null is null: method androidx.paging.CachedPagingDataKt.cachedIn, ...
0
votes
1
answer
653
views
Android Unit Test: Mockk io.mockk.MockKException: Missing calls inside every { ... } block
I have a simple function inside my repository class, that function will parse a static response from the asset and return the result. tried to write a unit test of that function but somehow my test is ...
1
vote
0
answers
120
views
Testing on Lottie Android - Assert color
In my Android application, I used to have a ProgressBar that, in a test, would check the color assigned to the view.
assertEquals(
ColorStateList.valueOf(
Color....
4
votes
1
answer
439
views
How is it possible to instantiate a ViewModel in a unit test?
The following codelab instantiates a ViewModel in a unit test without using Robolectric or any mock library.
https://developer.android.com/codelabs/basic-android-kotlin-compose-test-viewmodel
How is ...
2
votes
0
answers
236
views
How to mock Boolean field? Error Cannot mock/spy class java.lang.Boolean
I am trying to mock on field and return needed value but got error
here is error
Cannot mock/spy class java.lang.Boolean
Mockito cannot mock/spy because :
- Cannot mock wrapper types, String.class or ...
1
vote
1
answer
204
views
How (and should) I verify that an async internal method was called in State Unit Testing?
override fun getSomething(): LiveData<List<Content>> {
fakeDataSource.fetchSomethingAsync()
return contentDao.getSomething()
}
Here we have a repository method to get ...
5
votes
2
answers
4k
views
Jetpack Compose, how to test navigation?
I'm quite new in testing and I want to learn how do I test navigation which includes Jetpack Compose Ui Screens with ViewModels. How can I for example test that when I click on button in Home Screen, ...