Skip to main content

All Questions

Filter by
Sorted by
Tagged with
0 votes
1 answer
23 views

Unable to resolve duplicate class issue while adding dependencies in Android gradle for writing instrumented tests for Composable UI

I have a complex project where version for org.jetbrains.kotlinx:kotlinx-coroutines-android is forced to 1.6.4. I have used Jetpack composables for my UI screens. I want to write Instrumented Tests ...
Sarfaraz's user avatar
  • 376
0 votes
0 answers
12 views

Run Roboelectric in Unit Testing and Most Efficient way to perform instrument test at physical device

I'm doing some old codelab on testing here, But in the codelab it uses Roboelectric in UnitTest folder, but when I run that it stuck on this part Here's the code. @RunWith(AndroidJUnit4::class) class ...
archisei's user avatar
0 votes
0 answers
28 views

Android FragmentScenario androidTest prevent running network calls on launch and view model testing

I have an existing fragment class as part of a navigation graph component and uses Dagger to create instances of ViewModels scoped to the nav graph. However, I have a few questions about ...
MajinKenn's user avatar
3 votes
1 answer
66 views

Android instrumented tests not all played on some devices

I have an Android app with 225 espresso tests. Up to now, I have always been able to run all tests in a raw on all devices (Samsung smartphones and tablets, from Android 7 to 14) I now have a brand ...
Laurent D.'s user avatar
0 votes
1 answer
37 views

NoMatchingViewException error during Espresso test

I am doing an instrumentation test of Fragment is displayed or not. When I start the test it execute, I am able to see FragmentLogin view in physical device but test fail by saying androidx.test....
Dnveeraj's user avatar
  • 138
0 votes
0 answers
28 views

How to set up NavHost for android UI testing?

java.lang.IllegalArgumentException: Cannot navigate to NavDeepLinkRequest{ uri=android-app://androidx.navigation/movies/ }. Navigation graph has not been set for NavController androidx.navigation....
RocketMan's user avatar
1 vote
0 answers
78 views

Why Android enforces me to use Hilt if I want to test @AndroidEntryPoint annotated classes (UI TEST) but hilt can not provide Activity object

I am trying to test a Main Activity class that is @AndroidEntryPoint using Hilt Testing in my Android application. The PermissionHelper class is defined as follows: public class PermissionHelper { ...
Nadin Martini's user avatar
1 vote
0 answers
62 views

How to exclude app module from instrumented test?

After running ./gradlew connectedAndroidTest and removing androidTest directory and the any required setup with instrumented test from my app module build.gradle.kts, the task :app:...
Bitwise DEVS's user avatar
  • 3,370
0 votes
0 answers
25 views

How to test composables background?

I have an application written in compose and I want to test it's background based on state stored in viewmodel and interaction with the composable item, like: Box( modifier = Modifier ...
Arman TabibZadeh's user avatar
0 votes
0 answers
147 views

Cannot run Android Instrumentation test when enable R8

My app recently enabled the R8. My app can run fine when R8 is enabled. The UI Test can run when R8 is disabled, but when enabled, I got the "Caused by: java.lang.ClassNotFoundException: Didn't ...
Khoa Chau's user avatar
1 vote
1 answer
258 views

Run instrumented test with Gradle while skipping build and installation

Is there a way to run instrumented test with Android Gradle Plugin without running a build task and installation task? I need to do the installation of test APKs via adb for a very specific reason, ...
Undefined function's user avatar
0 votes
0 answers
27 views

Does Dagger 2 supports Instrumented Test in Android?

Is it possible to use Dagger 2 Android for instrumented test in a multi module project? I can't see related articles and SO question so here it is. Custom runner /** * Custom AndroidJUnitRunner to ...
Bitwise DEVS's user avatar
  • 3,370
0 votes
1 answer
113 views

Google Truth.assertThat.contains does not behave similar to List.contains

Using List.containsAll() and Truth.assertThat(list).contains(originalList) behaves differently. Working as expected assertThat(getItemsByChannelId.containsAll(entitiesChannelAPage2)).isTrue() Not ...
Bitwise DEVS's user avatar
  • 3,370
0 votes
0 answers
21 views

Zero tests started with gradle connectedAndroidTest or gradle connectedDebugAndroidTest

I have some Espresso tests in Android studio in kotlin Executed "gradle connectedAndroidTest" and "gradle connectedDebugAndroidTest" from cmd having emulator from Android studio ...
vasut alexandru's user avatar
0 votes
1 answer
63 views

Run instrumented test inside module's androidTest

Is it possible to run an instrumented test in an Android module that has no activity but uses AppCompat dependencies? I am attempting to run a simple test but only works if moved to app module. Util ...
Bitwise DEVS's user avatar
  • 3,370
2 votes
1 answer
282 views

Android instrumented tests BouncyCastle exception

Some time ago, my instrumented tests stopped working. I get an exception trying to sign the test apk from BouncyCastle. I did a git bisect to find the commit where the tests stopped working. I ...
johngray1965's user avatar
2 votes
0 answers
99 views

Override resource files in Android instrumented tests

Disclaimer: related but different from this, this and this. I would like to point AndroidManifest.xml to an xml resource file like this: <application [...] android:...
JonasVautherin's user avatar
1 vote
0 answers
339 views

Instrumented test uses main AndroidManifest instead of the test version

I am trying to uses OkHttp in some Android instrumented tests, but I get the following error: java.net.UnknownServiceException: CLEARTEXT communication to localhost not permitted by network security ...
JonasVautherin's user avatar
2 votes
0 answers
278 views

Why is it so slow to start instrumented test in Android Studio?

I have the latest version on Android studio (Giraffe) And I have built a very small app from the project wizard (the "empty activity" template) When I run the app several times consecutively,...
Laurent D.'s user avatar
9 votes
4 answers
1k views

App is uninstalled after playing instrumented tests since migration to Giraffe

I have used Flamingo for some time, and after playing an Espresso test, the app was still installed. Then I upgraded to Giraffe, and now, after playing an Espresso test, the app is uninstalled. I did ...
Laurent D.'s user avatar
0 votes
1 answer
160 views

In a Hilt Instrument Test, can you have two ViewModels for @BindValue?

I am having some issues with a instrument test using Hilt. The problem is that I have to deal with two viewModels, one for the activity and then one for the base class. Here is what I have: @RunWith(...
Kristy Welsh's user avatar
  • 8,490
2 votes
0 answers
350 views

kotlin android junit4 parameterized test

i got an issue, i try to do a multi argument parameterized test with junit for instrumented test: @RunWith(Parameterized::class) class PileAddEditTopbarColorTest( private val ...
arist0v's user avatar
  • 159
0 votes
1 answer
439 views

How to retry on failed Android instrumented tests?

I'm searching for a way to retry run failed Android instrumented tests or called integration tests/ui tests. I think there could have 3 ways of doing this. Retry with Jenkins stage script -> ...
Zhou Haibo's user avatar
  • 2,058
0 votes
1 answer
228 views

instrumentTesting with Espresso when facing with Splash Screen API and Navigation

How to perform Instrumental Testing or Android Testing when using Splash Screen API and Navigation. As we know, Activity is no longer needed to create splash screen, we just need to make new Theme to ...
dans's user avatar
  • 27
1 vote
1 answer
397 views

Running Tests doesn't work properly. Test Results 0/0 Android Instrumented Tests

After updating my project with following dependencies my tests stoped running. mockitoVersion = '5.3.0' dexMakerVersion = '2.28.3' espressoVersion = '3.5.1' -- ...
Xena Warrior Princess's user avatar
0 votes
1 answer
453 views

How to run/invoke Instrumented Tests from within Android App code (MainActivity)

In the current arrangement, on Android, Instrumented Tests can be invoked by following approaches: From within Android Studio -> Right click on the class saved under "androidTest" Fire ...
GBN's user avatar
  • 1
0 votes
1 answer
363 views

Is there any way to make the application not restart at each @Test while running the android UI tests, but run all the testcases without restarting?

In the app I'm testing during onboarding there are tutorial screens that I want to test in separate @Tests, but between tests the app quits and restarts and this causes the tutorial to skip and jump ...
Gábor Tachtler's user avatar
9 votes
3 answers
2k views

com.android.tools.r8.internal.Jc: Space characters in SimpleName exception are not allowed prior to DEX version 040

I'm trying to using backticks ` in the definition of my instrumented tests. I don't understand why compiler complains about a strange error: Caused by: com.android.tools.r8.internal.Jj: com.android....
Nicola Gallazzi's user avatar
0 votes
0 answers
152 views

INSTALL_FAILED_UPDATE_INCOMPATIBLE when restoring from AVD cache for CI/CD pipeline instrumented tests

I'm trying to make a github actions workflow to run instrumented tests on Android. My file has steps similar to: actions/checkout@v3 actions/setup-java@v3 gradle/gradle-build-action@v2 actions/cache@...
SmallGrammer's user avatar
  • 1,353
1 vote
1 answer
315 views

How to access application overlay windows from Android tests?

The app I am working on has an application overlay window implemented as floating button. It's defined with type as: if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) WindowManager.LayoutParams....
Crocodile's user avatar
  • 5,825
0 votes
1 answer
879 views

Android Studio can not find instrumented tests

I have an app with two flavour versions (pro and light) and I want to run instrumented tests. So I add two extra directories androidTestLight and androidTestPro (have three test folders androidTest, ...
Mr T's user avatar
  • 53
24 votes
3 answers
7k views

Android studio Instrumented Test stuck at: Task :app:connectedDebugAndroidTest

I have encountered a problem that when I tried to run Android Instrument test, android studio will start building, everything is good until it stuck to this line "> Task :app:...
GAME TTXD's user avatar
  • 271
0 votes
1 answer
397 views

How to get lifecycle owner in instrumented test android?

I have view model which can be provided via such code: val retrofitService = RetrofitService.getInstance(requireContext()) val mainRepository = MainRepository(retrofitService) val viewVM = ...
Andrew's user avatar
  • 2,147
0 votes
0 answers
322 views

How to make instrumented test if I need to use @Composable?

I had an instrumented test that worked, however, then was added additional param to the object which required to call the @Composable function, so the entire test method should be marked as @...
Sirop4ik's user avatar
  • 5,183
1 vote
2 answers
1k views

Testing WorkManager with custom initializer and Hilt

I am trying to implement instrumented test for my custom Work Manager which uses Hilt's @AssistedInject. My Work Manager performs perfect in an app but when I am trying to test it according to Google'...
Ridje's user avatar
  • 103
1 vote
1 answer
615 views

Android instrumented tests - Recreated Activity not picking up locale change, API <33

At least, it's not doing what I'd expect. Here's my situation -- I'm writing a feature to allow that allows users to make locale changes at runtime. Without any special handling, a locale change will ...
aormsby's user avatar
  • 176
2 votes
0 answers
678 views

Android instrument test in gitlab CI/CD runner, installed on a virtual machine

I'm struggling to run an android emulator in a GitLab CICD job. Right now we have Proxmox virtualization on bare metal which hosts some VMs. One of the VMs is a GitLab runner. The runner uses the ...
Ali Golmirzaei's user avatar
0 votes
1 answer
106 views

How do you get access to a testing device's files when running instrumentation tests for Android

I have set up a physical device with files that can be retrieved through the MediaStore. My goal is to retrieve these files through the MediaStore in an instrumented test. Currently, when I push the ...
John Glen's user avatar
  • 937
0 votes
0 answers
206 views

How can I fake dagger injection for Instrumented test in dynamic-feature modules?

I have a simple Note Taking Application. The Application has an app gradle module and editnote gradle dynamic feature-module. Hence my editnote gradle module will depend on app gradle module [because ...
user1105872's user avatar
0 votes
1 answer
118 views

Exchange testInstrumentationRunner with a runner derived from class not available at compile time

I want to use a custom testInstrumentationRunner for overriding the newInstance method in order to use a custom application: class UiTestJUnitRunner : AllureAndroidJUnitRunner() { override fun ...
ceedee's user avatar
  • 401
0 votes
1 answer
596 views

Composable does not remember input when changing configuration in test

I'm writing instrumented tests for a Jetpack Compose component. My composable uses rememberSaveable to remember between configuration changes (activity restarts): @Composable fun AddUserScreen() { ...
Mahozad's user avatar
  • 24.1k
1 vote
0 answers
613 views

java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/test/platform/io/FileTestStorage;

Firstly I did not have androidTest Package in my App, So I created using Run-> Record Espresso Test, So it Created an androidTest package. But Getting this Exception in Logcat while running an ...
Roop Kishore's user avatar
3 votes
2 answers
2k views

ComponentActivity ClassNotFoundException when trying to setup Instrumented tests, with Android Compose and Hilt

I'm setting up my first instrumented unit-test and getting an obscure crash in logcat. The emulator starts and immediately crashes when the app tries to open and the unit test doesn't even run because ...
David Aleksanyan's user avatar
1 vote
0 answers
40 views

Run connected test from terminal with dynamic module (dynamic module is not included in the test)

I'm trying to run connected instrumented tests from the terminal, but some tests are failing since the dynamic module is not included in the target apk. When I run these tests from Android Studio then ...
user2875643's user avatar
3 votes
2 answers
2k views

How to assert next started activity for a composable test?

I have a composable with a button that launches one of the native activities (Google Settings). To test this before compose (using Robolectric) I would do something like this: My test: @Test fun `...
Alix's user avatar
  • 2,827
2 votes
1 answer
530 views

context.startActivity not working for a single app in UiAutomator

I'm trying to launch a 3rd-party app using UiAutomator with this code: val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) device.pressHome() val context = ...
artem's user avatar
  • 16.7k
0 votes
0 answers
152 views

Android: How to do instrumented tests with mocked locations?

For instrumented tests of location services I need mocked locations. But the current concept from Android seems to be not very practical. In order to be allowed to use mocked locations the test-...
Sqrt-1764's user avatar
  • 331
3 votes
1 answer
509 views

How to test Alarm Manager using Unit Test or Instrumented Test in Android

I am facing an issue to test the alarms that set on alarm manager. I want to check the alarm manager using unit test or Instrumented test. val alarmManager1 = context.getSystemService(Context....
Muhammad Zaryab Rafique's user avatar
1 vote
1 answer
1k views

Android how to get XML output of Instrumented Tests

For the CI testing of my Android App I wrote some unit tests and let them run via gradle from the terminal. They all produce the typical junit XML output files in the build/test-results folder like ...
Tobias Reich's user avatar
  • 5,150
0 votes
1 answer
151 views

is there any solution to solve instrumented test on android

I'm trying to perform instrumented test on android studio using test lab, my project is developed using react native and imported to android studio, I recorded Test case using espresso. the whole ...
Raphking2 's user avatar