Skip to main content
Filter by
Sorted by
Tagged with
2 votes
1 answer
164 views

I'm working on unit tests for my Android app. My app has two flavors: "flavor 1" and "flavor 2", configured in default.gradle. Tests common to both are in test and I also have ...
Barry Fruitman's user avatar
0 votes
0 answers
172 views

When generating coverage report in Android unit test by selection option "Run **test with coverage", we see a lot of hilt generated classes being added to the report giving us wrong coverage ...
abhishek maharajpet's user avatar
0 votes
1 answer
209 views

I am testing a ViewModel using a fake repository which uses a StateFlow to store the fake data. This StateFlow is exposed as a normal Flow from the repository. In the ViewModel, I am mapping the ...
Kahan Bhalani's user avatar
0 votes
1 answer
139 views

I want to release current instance but that not working here is there any easier way to handle it. I have a class -> DownloadManager which is singleton And I have a @Before test which always ...
Priya's user avatar
  • 2,689
1 vote
1 answer
614 views

In my Android project, I have a file in res/raw/config.json. In Android application, this file can be accessed via resources.openRawResource(). Is there a way, how to access this file from Unit tests (...
Ariczek's user avatar
  • 314
1 vote
0 answers
96 views

Any idea on how to write unit test case for the below function: PendingIntent pendingIntent = new NavDeepLinkBuilder(context) .setGraph(R.navigation.flow_nav_graph) ....
Chaitanya Aggarwal's user avatar
-1 votes
1 answer
4k views

Mockk Error in android Koltin Unit test. matching with Two URL io.mockk.MockKException: Missing mocked calls inside every { ... } block: make sure the object inside the block is a mock @Before fun ...
Android Dev's user avatar
0 votes
2 answers
4k views

I am very new in Unit testing , i am trying to test my flow using Turbine library, it is not emitting all value, here is my test fun `send function should emit Loading and Content states`() = runTest ...
Jitendra Prajapati's user avatar
0 votes
1 answer
216 views

I am trying to test some file related logic in an Android unit test, but whenever I call file.exists() it always returns false for some reason. Here is a boiled down example of a test case I have: @...
kc_dev's user avatar
  • 830
0 votes
1 answer
709 views

I need to write unit tests for doing a paginated network request. First I implemented paging library logic to retrieve the data. I created a data source class and a repository class to get data from ...
Jona's user avatar
  • 283
1 vote
0 answers
432 views

The application in question has a logout function that among other things, performs a call to CookieManager.getInstance().removeAllCookies(null): fun logout(...) { ...
Orbit's user avatar
  • 2,415
2 votes
0 answers
94 views

I want to test that when i click on btnRestore , CloudRestoreService should be start. how to test this ? @Test fun testBtnRestore_expectedIntentCloudRestoreService() { Intents.init() onView(...
Laksh Lathiya's user avatar
1 vote
1 answer
2k views

Amateur question, but I can't seem to find an answer... I am writing unit tests using Mockito and I have a utils function (isOnline(context)) which checks if I am offline before making a network call. ...
Alon's user avatar
  • 983
3 votes
2 answers
749 views

This is util method for converting phone number format. fun String.toDisplayPhoneNumber(): String { return PhoneNumberUtils.formatNumber(this, Locale.getDefault().country).replace("+82 ",...
c-an's user avatar
  • 4,210
0 votes
1 answer
392 views

I set, testOptions { animationsDisabled = true unitTests.all { useJUnitPlatform() } } And I am using Java Home for Gradle JDK. The error is here: Execution ...
c-an's user avatar
  • 4,210
5 votes
1 answer
4k views

using mockk for unit test, and would like to mock the BuilConfig.DEBUG. io.mockk.mockkObject(BuildConfig::class) // or mockkStatic io.mockk.every { BuildConfig.DEBUG } returns true //&...
lannyf's user avatar
  • 11.1k
6 votes
1 answer
860 views

I am trying to set up unit tests for my application. But I am facing an issue with Segment This is my test class: @RunWith(RobolectricTestRunner::class) @Config(sdk = [Build.VERSION_CODES.O_MR1]) ...
hushed_voice's user avatar
  • 3,666
0 votes
1 answer
2k views

using io.mockk 1.11.0 having some class with @JvmStatic function class LogUtil { @JvmStatic fun logData(jsonStr: String) { val jsonObj = getDataJson(jsonStr) if (jsonObj == ...
lannyf's user avatar
  • 11.1k
1 vote
0 answers
726 views

I am new to writing Android Test Cases. I am trying to write a test case for a project which is already developed. It has so many Activities and Fragments and we are using Navigation Graph for ...
Aanal Shah's user avatar
  • 2,116
2 votes
0 answers
405 views

I have a fake API service that will mock the failure. So when it calls through paging source I should be getting PagingSource.LoadResult.Error of the type returned by API service. This is my test ...
user2934930's user avatar
  • 1,156
0 votes
1 answer
852 views

I am using Hilt for DI in my project. I am trying write unit test cases for LiveData object, but it's not coming under coverage. ViewModel @HiltViewModel class HealthDiagnosticsViewModel @Inject ...
Kunu's user avatar
  • 5,182
1 vote
1 answer
593 views

Is there a way to run a list of Robo Scripts (locally or to Firebase Test Lab) instead of running them one by one? The way to run Robo Scripts locally one at a time is the following: java -jar ...
Fivos's user avatar
  • 568
4 votes
1 answer
1k views

If I launch the app manually while espresso test case is running it works and test passed. But If i'm waiting to app launch automatically by espresso. It fails with below information. Any help please. ...
Praveen Kumar Sugumaran's user avatar
0 votes
1 answer
601 views

On android app, Having a java function JSONObject addToJson(@NonNull JSONObject jsonObject, @NonNull String key, boolean value){ try { jsonObject.put(key, value); } catch (...
lannyf's user avatar
  • 11.1k
0 votes
1 answer
524 views

I have a question related to Unit testing in android. The app is written in Kotlin, MVVM architecture, Dagger-Hilt, Room, etc… I have written all the tests for Room DAOs, according to official docs. I ...
Daguna's user avatar
  • 181
1 vote
0 answers
206 views

Having an android library project working fine with AS 4.1.2. Just installed Android studio (fox) 2020.3.1 patch 3 without change anything (except set the sdk jre to java 8, version 18.6.0_60, since ...
lannyf's user avatar
  • 11.1k
1 vote
0 answers
1k views

Having an android library project, it has been built and unit tested fine with android studio 4.1.2. Now change to use android studio (fox) 2020.3.1 path 3. It starts to get error Cannot run gradle ...
lannyf's user avatar
  • 11.1k
0 votes
1 answer
2k views

I have added Robolectric to get support of Shadow APIs for writing unit tests. Able to get coverage percentage through default Intellij code coverage tool in Android Studio. Now trying to add JaCoCo ...
Prat's user avatar
  • 142
0 votes
1 answer
541 views

on android app, using Broadcastreceiver to handle the notification click. public class NotificationReceiver extends BroadcastReceiver { public void onReceive(final Context context, final Intent ...
lannyf's user avatar
  • 11.1k
0 votes
1 answer
175 views

I am trying to write a unit test case for android using Junit-5 and mockito But how to write test case for this kind of function when there is a return statment ```public void doSomething() { ...
Hardik Lakum's user avatar
2 votes
4 answers
4k views

Test Events were not Received Error: NoClassDefFoundError on running unit test after updating android studio to ArticFox | 2020.3.1. Below is the full error: java.lang.NoClassDefFoundError: jdk/...
Varun A M's user avatar
  • 1,162
0 votes
1 answer
330 views

Having a static function isNotificationsEnabled which has a if block in the channels for loop to check the notification channel if there is any: class Utils { @NonNull static List<...
lannyf's user avatar
  • 11.1k
5 votes
0 answers
3k views

I'm trying to run a unit test on my RecyclerView. For my first test, I want to see if the RecyclerView is displayed. @RunWith(RobolectricTestRunner::class) class WordListFragmentTest { // ...
Shawn's user avatar
  • 1,382
0 votes
1 answer
645 views

The answer to this question is not "Android unit tests cannot access Android stack modules such as the Room database because on your desktop they are all stubbed out." I had a bunch of unit ...
Phlip's user avatar
  • 5,350
1 vote
1 answer
2k views

How to start a fragment with a LiveData observer in the test scope with Robolectric Fragment class MyFragment(private val viewModel: MyViewModel) : Fragment() { ... fun myObserver { ....
Shawn's user avatar
  • 1,382
1 vote
0 answers
663 views

I'm trying to unit test an observable in a viewmodel but I'm getting the following error. I have included the observable in question... getRepository() .executeGetAccount() ...
devmike01's user avatar
  • 1,975
1 vote
1 answer
283 views

I'm learning TDD with my toy project with Android Clean Architecture. I want to know how to process my Unit Test. I want to do TDD with my search features, in this case, Should I create my UseCase and ...
HyeonSeok's user avatar
  • 599
2 votes
0 answers
868 views

I need to write Unit test cases for Android Biometric prompt. I tried to search many links but didn't get the proper direction. Need to write unit test cases for UI Biometric is visible or not. Do I ...
Pro_And's user avatar
  • 21
1 vote
0 answers
815 views

I'm using Mockito for unit testing. I want to test my usecase and with mock repository but there's some problem. I had my repository's function returns arraylist by using mockito. (here's code below) `...
HyeonSeok's user avatar
  • 599
1 vote
1 answer
1k views

I have a method that makes an API call and if an error occurs it will retry the call with a different instance of the same service API. var getResponse = myApi?.getCodeApi() if (...
abhishek maharajpet's user avatar
0 votes
1 answer
117 views

I have a coroutine in my viewModel which runs perfectly fine. When I try to unit test the same, it throws the following error "Could not create instance for [type:Factory,primary_type:..MyService&...
abhishek maharajpet's user avatar
0 votes
1 answer
219 views

I am not extending any interface and all my interfaces are independent. While performing unit testing I am getting the following exception. During normal API calls, everything works fine. val ...
abhishek maharajpet's user avatar
0 votes
1 answer
1k views

I am currently unit testing my local data source which uses Room. I created a test class: /** * Integration test for the [WatchListLocalDataSource]. */ @RunWith(AndroidJUnit4::class) @MediumTest ...
Ziv Kesten's user avatar
  • 1,270
0 votes
1 answer
399 views

On the way of learning unit test with mockK I came across with this scenario: MyViewModel: private val _spinner: MutableLiveData<Boolean> = MutableLiveData() val getSpinner : LiveData<...
blackHawk's user avatar
  • 6,347
6 votes
3 answers
2k views

My question is actually quite generic. I want to know how to unit test a Room Dao query that returns a PagingSource From Paging 3. I have a Room Dao query: @Query("SELECT * FROM database"...
rabyunghwa's user avatar
6 votes
1 answer
4k views

I need some help about writing unit tests in android, related to the viewmodel, livedata and flow mechanics and dispatching. First of all, im writing unit tests, and not instrumeted test. Actually, im ...
Marlon López's user avatar
3 votes
2 answers
781 views

I am trying to run android app crawler: https://developer.android.com/training/testing/crawler Also looked at this: https://android.jlelse.eu/test-robo-scripts-locally-useful-for-firebase-test-lab-pre-...
Michael A's user avatar
  • 5,890
5 votes
1 answer
11k views

I'm writing a unit test. Below is my code. The architecture is MVVM using Dagger2. I'm calling the login function residing in the LoginViewModel, which is notifying the getLoginState function. The ...
Ahmad Shahwaiz's user avatar
0 votes
1 answer
502 views

I am trying to run the simple unit test by following the example here: https://developer.android.com/training/testing/unit-testing/local-unit-tests import android.content.Context; import androidx.test....
Cb32019's user avatar
  • 315
0 votes
0 answers
133 views

I built an android app using volley to fetch data from a remote server. I am trying to test the app using espresso. can anyone help me with the code for that? if I take the simplest example, I am ...
Ariel Applebaum's user avatar